Package javax.swing.text

Examples of javax.swing.text.Document.insertString()


      doc.remove(0, doc.getLength());
      doc.insertString(doc.getLength(), "This is what an ", defaultStyle);
      doc.insertString(doc.getLength(), "annotation", this.currentStyle);
      doc.insertString(doc.getLength(), " of type ", defaultStyle);
      doc.insertString(doc.getLength(), this.currentTypeName, this.currentStyle);
      doc.insertString(doc.getLength(), " will look like.", defaultStyle);
    } catch (BadLocationException e) {
      // assert(false);
    }
    this.textPane.repaint();
  }
View Full Code Here


        level = e.getMarkupDepth();
        if (level > 3) {
          level = 3;
        }
        s = text.substring(e.getStart(), e.getEnd());
        doc.insertString(doc.getLength(), s, styleArray[level]);
        // System.out.println("Adding text: \"" + s + "\"\nat level: " +
        // level);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
View Full Code Here

    String s;
    try {
      for (int i = 0; i < extents.length; i++) {
        e = extents[i];
        s = text.substring(e.getStart(), e.getEnd());
        doc.insertString(doc.getLength(), s, e.getStyle());
        // System.out.println("Adding text: \"" + s + "\"\nat level: " +
        // level);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
View Full Code Here

    public void testJTextFieldDocumentStringInt() {
        String str1 = "AAA";
        String str2 = "testJTextFieldDocumentStringInt()";
        Document doc = new PlainDocument();
        try {
            doc.insertString(0, str2, null);
        } catch (BadLocationException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), false);
        }
        JTextField tf = new JTextField(doc, str2, 8);
        assertEquals(str2, tf.getText());
View Full Code Here

        assertEquals(str2, tf.getText());
        assertEquals(doc, tf.getDocument());
        assertEquals(8, tf.getColumns());
        doc = new PlainDocument();
        try {
            doc.insertString(0, str2, null);
        } catch (BadLocationException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), false);
        }
        tf = new JTextField(doc, null, 6);
        assertEquals(str2, tf.getText());
View Full Code Here

    }

    public void testJTextAreaDocumentStringintint() {
        Document doc = new PlainDocument();
        try {
            doc.insertString(0, str2, null);
            ExtJTextArea ta = new ExtJTextArea(doc, str1, 3, 8);
            assertEquals(str1, ta.getText());
            assertEquals(doc, ta.getDocument());
            assertEquals(3, ta.getRows());
            assertEquals(8, ta.getColumns());
View Full Code Here

            assertEquals(3, ta.getRows());
            assertEquals(8, ta.getColumns());
            assertFalse(ta.getLineWrap());
            assertFalse(ta.getWrapStyleWord());
            doc = new PlainDocument();
            doc.insertString(0, str2, null);
            ta = new ExtJTextArea(doc, null, 5, 6);
            assertEquals(str2, ta.getText());
            ta = new ExtJTextArea(doc, "", 5, 6);
            assertEquals("", ta.getText());
            try {
View Full Code Here

    }

    public void testJTextAreaDocument() {
        Document doc = new PlainDocument();
        try {
            doc.insertString(0, str2, null);
        } catch (BadLocationException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), false);
        }
        ExtJTextArea ta = new ExtJTextArea(doc);
        assertEquals(str2, ta.getText());
View Full Code Here

                if (aDiff.operation == Operation.INSERT) {
                  // Insertion
                  text = text.substring(0, start_loc + index2) + aDiff.text
                      + text.substring(start_loc + index2);
                  try {
                    doc.insertString(start_loc + index2 - nullPadding.length(),
                        aDiff.text, null);
                  } catch (BadLocationException e) {
                    e.printStackTrace();
                  }
                  for (int i = 0; i < offsets.size(); i++) {
View Full Code Here

  }

  public void print(String s) {
    Document d = editor.getDocument();
    try {
      d.insertString(d.getLength(), s, null);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.