Package javax.swing.text

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


    String replacement = getReplacementText(c, textComp.getDocument(),
                        start, len);

    caret.setDot(start);
    caret.moveDot(dot);
    textComp.replaceSelection(replacement);
    /*
    Document doc = textComp.getDocument();
try {
    if (doc instanceof AbstractDocument) {
      ((AbstractDocument)doc).replace(start, len, replacement, null);
View Full Code Here


   
      // Are they at or past the end of the parameters?
      if (dot>=maxPos.getOffset()-1) { // ">=" for overwrite mode

        if (dot==maxPos.getOffset()) { // Happens in overwrite mode
          tc.replaceSelection(Character.toString(end));
        }

        else { // Typical case.
          // Try to decide if we're closing a paren that is a part
          // of the (last) arg being typed.
View Full Code Here

          if (text!=null) {
            char start = pc.getProvider().getParameterListStart();
            int startCount = getCount(text, start);
            int endCount = getCount(text, end);
            if (startCount>endCount) { // Just closing a paren
              tc.replaceSelection(Character.toString(end));
              return;
            }
          }
          tc.setCaretPosition(maxPos.getOffset());
        }
View Full Code Here

      }

      // If not (in the middle of parameters), just insert the paren.
      else {
        tc.replaceSelection(Character.toString(end));
      }

    }

    public String getArgumentText(int offs) {
View Full Code Here

                    }

                    target.moveCaretPosition(endOffs);

                    // and then delete it
                    target.replaceSelection("");
                    beep = false;
                } catch (BadLocationException exc) {
                    // nothing to do, because we set beep to true already
                }
            }
View Full Code Here

                if (!failed) {
                    target.moveCaretPosition(offs);

                    // and then delete it
                    target.replaceSelection("");
                    beep = false;
                }
            }

            if (beep) {
View Full Code Here

      if (this._component instanceof JTextComponent) {
        JTextComponent comp = (JTextComponent)this._component;
        int start = comp.getSelectionStart();
        int end = comp.getSelectionEnd();
        if (start != end) {
              comp.replaceSelection("");
              // TF:Mar 4, 2010:If we remove a selection from a datafield, this datafield will fire
              // AfterValueChange events, even though the change is programmatic. Hence, we must mirror this.
              if (comp instanceof DataField) {
                ((DataField)comp).postAfterValueChange(false);
              }
View Full Code Here

    String replacement = getReplacementText(c, textComp.getDocument(), start, len);

    caret.setDot(start);
    caret.moveDot(dot);
    textComp.replaceSelection(replacement);

    if (isParameterAssistanceEnabled() &&
            (c instanceof ParameterizedCompletion)) {
      ParameterizedCompletion pc = (ParameterizedCompletion)c;
      displayDescriptionToolTip(pc, true);
View Full Code Here

        }
        final Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this);
        if(contents.isDataFlavorSupported(DataFlavor.stringFlavor)){
          try {
            String text = (String) contents.getTransferData(DataFlavor.stringFlavor);
            target.replaceSelection(text);
          }
          catch (Exception ex) {
          }
        }
      }
View Full Code Here

public class UITools {
  @SuppressWarnings("serial")
    public static final class InsertEolAction extends AbstractAction {
        public void actionPerformed(ActionEvent e) {
          JTextComponent c = (JTextComponent) e.getSource();
          c.replaceSelection("\n");
        }
    }

  public static final String MAIN_FREEPLANE_FRAME = "mainFreeplaneFrame";
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.