Package javax.swing.text

Examples of javax.swing.text.JTextComponent.viewToModel()


      if (c.getParent() instanceof JViewport) {
        JViewport viewport = (JViewport) c.getParent();
        Point p = viewport.getViewPosition();

        if (this.direction == SwingConstants.NORTH) {
          c.setCaretPosition(c.viewToModel(p));
        } else {
          p.y += viewport.getExtentSize().height;
          c.setCaretPosition(c.viewToModel(p));
        }
      }
View Full Code Here


        if (this.direction == SwingConstants.NORTH) {
          c.setCaretPosition(c.viewToModel(p));
        } else {
          p.y += viewport.getExtentSize().height;
          c.setCaretPosition(c.viewToModel(p));
        }
      }

      textActn.actionPerformed(e);
    }
View Full Code Here

      dtde.rejectDrag();

    if( dtde.getDropTargetContext().getComponent() instanceof JTextComponent )
    {
      JTextComponent textField = ( JTextComponent )dtde.getDropTargetContext().getComponent();
      int pos = textField.viewToModel( dtde.getLocation() );
      if( pos != -1 )
      {
        textField.setCaretPosition( pos );
        textField.getCaret().setVisible( true );
      }
View Full Code Here

    protected Step createClick(Component comp, int x, int y,
                               int mods, int count) {
        if (mods == MouseEvent.BUTTON1_MASK && count == 1) {
            ComponentReference cr = getResolver().addComponent(comp);
            JTextComponent tc = (JTextComponent)comp;
            int index = tc.viewToModel(new Point(x, y));
            return new Action(getResolver(), null,
                              "actionClick", new String[] {
                                  cr.getID(),
                                  String.valueOf(index),
                              }, JTextComponent.class);
View Full Code Here

      final Caret caret = jText.getCaret();
      int offs = Math.min(caret.getDot(), caret.getMark());
      final Point p = jText.getMousePosition();
      if (p != null) {
        // use position from mouse click and not from editor cursor position
        offs = jText.viewToModel(p);
      }
      try {
        final Document doc = jText.getDocument();
        if (offs > 0 && (offs >= doc.getLength() || Character.isWhitespace(doc.getText(offs, 1).charAt(0)))) {
          // if the next character is a white space then use the word on the left site
View Full Code Here

            dtde.rejectDrag();
        }

        if (dtde.getDropTargetContext().getComponent() instanceof JTextComponent) {
            JTextComponent textField = (JTextComponent) dtde.getDropTargetContext().getComponent();
            int pos = textField.viewToModel(dtde.getLocation());
            if (pos != -1) {
                textField.setCaretPosition(pos);
                textField.getCaret().setVisible(true);
            }
        }
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.