Package javax.swing.text

Examples of javax.swing.text.Position


    harness.checkPoint("testPositions");
    PlainDocument d = new PlainDocument();
    try
    {
      d.insertString(0, "ABCDEF", 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(2);
      harness.check(p2.getOffset(), 2);
      Position p3 = d.createPosition(3);
      harness.check(p3.getOffset(), 3);
      Position p4 = d.createPosition(4);
      harness.check(p4.getOffset(), 4);
      Position p5 = d.createPosition(5);
      harness.check(p5.getOffset(), 5);
      Position p6 = d.createPosition(6);
      harness.check(p6.getOffset(), 6);
     
      d.remove(2, 2);
      harness.check(p0.getOffset(), 0);
      harness.check(p1.getOffset(), 1);
      harness.check(p2.getOffset(), 2);
      harness.check(p3.getOffset(), 2);     
      harness.check(p4.getOffset(), 2);     
      harness.check(p5.getOffset(), 3);     
      harness.check(p6.getOffset(), 4);
     
      d.remove(0, 1);
      harness.check(p0.getOffset(), 0);
      harness.check(p1.getOffset(), 0);
      harness.check(p2.getOffset(), 1);
      harness.check(p3.getOffset(), 1);     
      harness.check(p4.getOffset(), 1);     
      harness.check(p5.getOffset(), 2);     
      harness.check(p6.getOffset(), 3);
     
    }
    catch (BadLocationException e)
    {
    }
View Full Code Here


  {
    harness.checkPoint("test1");
    PlainDocument d = new PlainDocument();
    try
    {
      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);
      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);
     
      d.remove(2, 3);
      harness.check(p0.getOffset(), 0);
      harness.check(p1.getOffset(), 2);
      harness.check(p2.getOffset(), 3);
      harness.check(p3.getOffset(), 4);     
    }
    catch (BadLocationException e)
    {
    }
  }
View Full Code Here

   *         into the text area.
   * @see #removeTrackingIcon(Object)
   */
  public GutterIconInfo addOffsetTrackingIcon(int offs, Icon icon)
                        throws BadLocationException {
    Position pos = textArea.getDocument().createPosition(offs);
    GutterIconImpl ti = new GutterIconImpl(icon, pos);
    if (trackingIcons==null) {
      trackingIcons = new ArrayList(1); // Usually small
    }
    int index = Collections.binarySearch(trackingIcons, ti);
View Full Code Here

   * @param doc
   * @param choice
   */
  public void insertIfClause(int choice){
   
    Position pos = doc.getEndPosition();
    int start = pos.getOffset();
   
    try {
      replaceSelection("");
      doc.insertString(positionCaret, "if", styleTable.getIfStyle());
      doc.insertString(positionCaret, " ", styleTable.getDefaultStyle());
View Full Code Here

        int end = errorText.getCaretPosition();
        errorText.getCaret().setDot(end - 1);
    }//GEN-LAST:event_copyButtonActionPerformed

    private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
        Position end = errorText.getDocument().getEndPosition();

        errorText.getCaret().setDot(0);
        errorText.getCaret().moveDot(end.getOffset() - 1);
        errorText.getCaret().setSelectionVisible(true);
    }//GEN-LAST:event_selectButtonActionPerformed
View Full Code Here

        doc.runAtomic(new Runnable() {

            public void run() {
                try {
                    Position position = doc.createPosition(offset);
                    doc.remove(offset, len);
                    doc.insertString(position.getOffset(), textBuffer.toString(), null);
                } catch (BadLocationException ble) {
                    // nothing can be done to update
                }
            }
        });
View Full Code Here

   *         into the text area.
   * @see #removeTrackingIcon(Object)
   */
  public GutterIconInfo addOffsetTrackingIcon(int offs, Icon icon, String tip)
                        throws BadLocationException {
    Position pos = textArea.getDocument().createPosition(offs);
    GutterIconImpl ti = new GutterIconImpl(icon, pos, tip);
    if (trackingIcons==null) {
      trackingIcons = new ArrayList(1); // Usually small
    }
    int index = Collections.binarySearch(trackingIcons, ti);
View Full Code Here

   *         into the text area.
   * @see #removeTrackingIcon(Object)
   */
  public GutterIconInfo addOffsetTrackingIcon(int offs, Icon icon)
                        throws BadLocationException {
    Position pos = textArea.getDocument().createPosition(offs);
    GutterIconImpl ti = new GutterIconImpl(icon, pos);
    if (trackingIcons==null) {
      trackingIcons = new ArrayList(1); // Usually small
    }
    int index = Collections.binarySearch(trackingIcons, ti);
View Full Code Here

  private String getDescription(String name) {
    return NbBundle.getMessage(HintsCollector.class, name);
  }

  private Position createPosition(final int pos) {
    return new Position() {
      @Override
      public int getOffset() {
        return pos;
      }
    };
View Full Code Here

TOP

Related Classes of javax.swing.text.Position

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.