Examples of viewToModel()


Examples of javax.swing.JTextPane.viewToModel()

  public void mouseMoved(MouseEvent ev) {
        JTextPane editor = (JTextPane) ev.getSource();
        editor.setEditable(false);
          Point pt = new Point(ev.getX(), ev.getY());
          int pos = editor.viewToModel(pt);
          if (pos >= 0) {
            Document eDoc = editor.getDocument();
            if (eDoc instanceof DefaultStyledDocument) {
              DefaultStyledDocument hdoc =
                (DefaultStyledDocument) eDoc;
View Full Code Here

Examples of javax.swing.JTextPane.viewToModel()

  public void mouseClicked(MouseEvent ev) {
      JTextPane editor = (JTextPane) ev.getSource();
       editor.setEditable(false);
        Point pt = new Point(ev.getX(), ev.getY());
        int pos = editor.viewToModel(pt);
        if (pos >= 0) {
          Document eDoc = editor.getDocument();
          if (eDoc instanceof DefaultStyledDocument) {
            DefaultStyledDocument hdoc =
              (DefaultStyledDocument) eDoc;
View Full Code Here

Examples of javax.swing.plaf.TextUI.viewToModel()

    // try to get the first element still shown in the viewport
    Rectangle vr = viewport.getViewRect();
    TextUI ui1 = editor.getUI();

    int p0 = ui1.viewToModel(editor, new Point(vr.x, vr.y));
    int p1 =
        ui1.viewToModel(editor, new Point(vr.x + vr.width, vr.y + vr.height));

    // find elements in document that contain p0 and p1
    int start =
View Full Code Here

Examples of javax.swing.plaf.TextUI.viewToModel()

    Rectangle vr = viewport.getViewRect();
    TextUI ui1 = editor.getUI();

    int p0 = ui1.viewToModel(editor, new Point(vr.x, vr.y));
    int p1 =
        ui1.viewToModel(editor, new Point(vr.x + vr.width, vr.y + vr.height));

    // find elements in document that contain p0 and p1
    int start =
        editor.getDocument().getDefaultRootElement().getElementIndex(p0);
    int end = editor.getDocument().getDefaultRootElement().getElementIndex(p1);
View Full Code Here

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

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

        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

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

      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

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

    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

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

      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

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

            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.