Package javax.swing.text

Examples of javax.swing.text.Element


   */
  protected void appendString(final String text) {
    final HTMLDocument doc = (HTMLDocument) textPane.getDocument();

    try {
      final Element root = doc.getParagraphElement(0);
      doc.insertBeforeEnd(root, text);
    } catch (final BadLocationException e) {
      logger.error(e, e);
    } catch (final IOException e) {
      logger.error(e, e);
View Full Code Here


  {
    JTextArea textArea = _consoleForm._output;
    textArea.append(line + "\n");
    if (textArea.getLineCount() > maxLines)
    {
      Element root = textArea.getDocument().getDefaultRootElement();
      Element firstLine = root.getElement(0);

      try
      {
        textArea.getDocument().remove(0, firstLine.getEndOffset());
      }
      catch (Exception ble)
      {
        System.out.println(ble.getMessage());
      }
View Full Code Here

          }

          public String getText() {
            final int caretPosition = playListTextArea
                .getDocument().getLength();
            final Element root = playListTextArea.getDocument()
                .getDefaultRootElement();
            String text = "1"
                + System.getProperty("line.separator");
            for (int i = 2; i < (root
                .getElementIndex(caretPosition) + 2); i++) {
              text += i + System.getProperty("line.separator");
            }
            return text;
          }
View Full Code Here

    return panel;
  }

  void setstatusMsg(JTextPane2 pane2) {
    int off = pane2.getCaretPosition();
    Element map = pane2.getDocument().getDefaultRootElement();
    int currLine = map.getElementIndex(off);
    int numLines = map.getElementCount();
    statusMsg.setText(' ' + FBEdit.getMessage("menu.line") + " " + (currLine + 1) + " / " + numLines);
  }
View Full Code Here

    public void testGetRootView() {
        BasicTextUI ui = getBasicTextUI(jta);
        View rootView = ui.getRootView(jta);
        AbstractDocument doc = (AbstractDocument) jta.getDocument();
        Element rootElement = jta.getDocument().getDefaultRootElement();
        assertEquals(1, rootView.getViewCount());
        View sonRootView = rootView.getView(0);
        assertNotNull(sonRootView);
        assertEquals(0, sonRootView.getViewCount());
        assertEquals(rootElement, rootView.getElement());
View Full Code Here

         *
         */
    }

    public void testCreateElementintint() {
        Element elem = jta.getDocument().getDefaultRootElement();
        assertNull(basicTextUI.create(elem));
        assertNull(basicTextUI.create(elem, 0, 5));
    }
View Full Code Here

    }

    public void testSetParent_View() {
        // Regression test for HARMONY-1767
        PlainDocument doc = new PlainDocument();
        Element e = doc.getDefaultRootElement();
        ComponentView obj = new ComponentView(new TestElement());
        obj.setParent(new PlainView(e));
   
View Full Code Here

        assertFalse(jep1.getScrollableTracksViewportWidth());
    }

    private AttributeSet getAttributeSetByIndex(final AbstractDocument d, final int offset) {
        AttributeSet as = null;
        Element elem = d.getDefaultRootElement();
        while (elem.getElementCount() > 0) {
            elem = elem.getElement(elem.getElementIndex(offset));
            as = elem.getAttributes();
        }
        return as;
    }
View Full Code Here

    }

    public void testGetParagraphAttributes() {
        // init paragraph attributeSet
        textPane.setCaretPosition(1);
        Element paragraph = textPane.getStyledDocument().getParagraphElement(
                textPane.getCaretPosition());
        attrs = new SimpleAttributeSet();
        StyleConstants.setStrikeThrough(attrs, true);
        StyleConstants.setAlignment(attrs, StyleConstants.ALIGN_CENTER);
        textPane.getStyledDocument().setParagraphAttributes(paragraph.getStartOffset(),
                paragraph.getEndOffset() - paragraph.getStartOffset(), attrs, true);
        // tests
        AttributeSet textAttrs;
        textPane.setCaretPosition(1);
        textAttrs = textPane.getParagraphAttributes();
        assertFalse(StyleConstants.isUnderline(textAttrs));
View Full Code Here

            public int getIconHeight() {
                return 40;
            }
        });
        assertAttrubutes(attrs, false, false, false, false, false, false);
        Element iconElement = textPane.getStyledDocument().getDefaultRootElement()
                .getElement(0).getElement(1);
        AttributeSet attributes = iconElement.getAttributes();
        assertNotNull(attributes.getAttribute(StyleConstants.IconAttribute));
        assertAttrubutes(attributes, false, false, false, false, false, false);
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.