Package javax.swing.text

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


   
    // negative index
    boolean pass = false;
    try
    {
      d.insertString(-1, "XYZ", SimpleAttributeSet.EMPTY);
    }
    catch (Exception e)
    {
      pass = e instanceof BadLocationException;
    }
View Full Code Here


    // index > length
    pass = false;
    try
    {
      d.insertString(2, "XYZ", SimpleAttributeSet.EMPTY);
    }
    catch (BadLocationException e)
    {
      pass = true;
    }
View Full Code Here

 
    // null string is OK (ignored)
    pass = true;
    try
    {
      d.insertString(0, null, SimpleAttributeSet.EMPTY);
    }
    catch (Exception e)
    {
      pass = false;
    }
View Full Code Here

   
    // null attribute set is OK
    pass = true;
    try
    {
      d.insertString(0, "ABC", null);
    }
    catch (Exception e)
    {
      pass = false;
    }
View Full Code Here

  {
    harness.checkPoint("testPositions");
    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

  {
    PlainDocument pd = new PlainDocument();

    try
      {
        pd.insertString(0, initialContent, null);

        return pd;
      }
    catch (BadLocationException ble)
      {
View Full Code Here

    PlainDocument d = new PlainDocument();
   
    harness.check(d.getLength(), 0);
    try
    {
      d.insertString(0, "ABC", null);
    }
    catch (BadLocationException e)
    {
      // ignore - checks will fail if this happens
    }
View Full Code Here

    harness.check(d.getLength(), 3);
   
    // try adding a string with a '\n'
    try
    {
      d.insertString(0, "ABC\n", null);
    }
    catch (BadLocationException e)
    {
      // ignore - checks will fail if this happens
    }
View Full Code Here

    PlainDocument doc = new PlainDocument();
    doc.addDocumentListener(new TestListener());

    try
      {
        doc.insertString(0, "abcde\nabcdef\nabcde\n", null);
        doc.insertString(15, "abcdefghijklmn\n", null);
      }
    catch (BadLocationException ex)
      {
        h.fail("Unexpected BadLocationException");
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.