Package javax.swing.text

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


    int index0 = -1;
    int index1 = -1;

    try
      {
        pd.insertString(0, "abc\ndef\n", null);

        // Delete the 'c'.
        pd.remove(2, 1);

        Element re = pd.getDefaultRootElement();
View Full Code Here


  public void test(TestHarness h)
  {
    PlainDocument doc = new PlainDocument();
    try
      {
        doc.insertString(0, "123456789", null);
      }
    catch (BadLocationException ex)
      {
        RuntimeException rte = new RuntimeException();
        rte.initCause(ex);
View Full Code Here

    h.check(zone.getStartOffset(), 0);
    h.check(zone.getEndOffset(), 9);
    // Check if the zone follows document insertions (via Positions).
    try
      {
        doc.insertString(5, "abcde", null);
      }
    catch (BadLocationException ex)
      {
        RuntimeException rte = new RuntimeException();
        rte.initCause(ex);
View Full Code Here

    {
      Position p0 = d.createPosition(0);
      harness.check(p0.getOffset(), 0);
      Position p1 = d.createPosition(1);
      harness.check(p1.getOffset(), 1);
      d.insertString(0, "ABC", null);
      harness.check(p0.getOffset(), 0);
      harness.check(p1.getOffset(), 4);
    }
    catch (BadLocationException e)
    {
View Full Code Here

  {
    harness.checkPoint("test2");
    PlainDocument d = new PlainDocument();
    try
    {
      d.insertString(0, "ABC", null);
      Position p0 = d.createPosition(0);
      harness.check(p0.getOffset(), 0);
      Position p1 = d.createPosition(1);
      harness.check(p1.getOffset(), 1);
      Position p2 = d.createPosition(3);
View Full Code Here

      Position p2 = d.createPosition(3);
      harness.check(p2.getOffset(), 3);
      Position p3 = d.createPosition(4);
      harness.check(p3.getOffset(), 4);
     
      d.insertString(1, "XYZ", null);
      harness.check(p0.getOffset(), 0);
      harness.check(p1.getOffset(), 4);
      harness.check(p2.getOffset(), 6);
      harness.check(p3.getOffset(), 7);
     
View Full Code Here

                        // u.openStream(MimeTypeConstants.MIME_TYPES_SVG);

                        Reader in = XMLUtilities.createXMLDocumentReader(is);
                        int len;
                        while ((len=in.read(buffer, 0, buffer.length)) != -1) {
                            doc.insertString(doc.getLength(),
                                             new String(buffer, 0, len), null);
                        }

                        ta.setDocument(doc);
                        ta.setEditable(false);
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

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.