Package javax.swing.text

Examples of javax.swing.text.JTextComponent$CaretEventImpl


    private void updateFormItemsFromGui(List<FormItem> items) {
        for (FormItem item : items) {
            JComponent field = item.getField();
            if (field instanceof JTextComponent) {
                JTextComponent textComponent = (JTextComponent) field;
                item.setCurrentValue(textComponent.getText());

            } else if (field instanceof JComboBox) {
                @SuppressWarnings("unchecked")
                JComboBox<String> box = (JComboBox<String>) field;
                String value = (String) box.getSelectedItem();
View Full Code Here


            super(L10N.getLocalString("txt.cut", "Cut"));
        }

        @Override
        public void actionPerformed(ActionEvent evt) {
            JTextComponent text = getTextComponent(evt);

            if (text == null) {
                return;
            }

            text.cut();
        }
View Full Code Here

            super(L10N.getLocalString("txt.copy", "Copy"));
        }

        @Override
        public void actionPerformed(ActionEvent evt) {
            JTextComponent text = getTextComponent(evt);

            if (text == null) {
                return;
            }

            text.copy();
        }
View Full Code Here

            super(L10N.getLocalString("txt.paste", "Paste"));
        }

        @Override
        public void actionPerformed(ActionEvent evt) {
            JTextComponent text = getTextComponent(evt);

            if (text == null) {
                return;
            }

            text.paste();
        }
View Full Code Here

  public J2DTextComponentAdapter(String varName) {
    super(varName);
  }

  protected Component createWidget() {
    JTextComponent jtc = createTextComponent();
    requestGlobalNewName();
    jtc.setText(getName());
    Dimension size = getInitialSize();
    jtc.setSize(size);
    jtc.doLayout();
    jtc.validate();
    return jtc;
  }
View Full Code Here

  protected abstract JTextComponent createTextComponent();

  @Override
  public void requestNewName() {
    super.requestNewName();
    JTextComponent jtc = (JTextComponent) getWidget();
    jtc.setText(getName());
  }
View Full Code Here

    // Scroll all the text fields (JTextComponent) so that the caret will be visible
    // when they are focused.
    protected void scrollTextFields(Component c) {
        if (c instanceof JTextComponent) {
            JTextComponent tc = (JTextComponent)c;
            if (tc.getDocument() != null && tc.getDocument().getLength() > 0) {
                // Reset the caret position to force a scroll of
                // the text component to the proper place
                int position = tc.getCaretPosition();
                int tempPosition = (position > 0) ? 0 : 1;
                tc.setCaretPosition(tempPosition);
                tc.setCaretPosition(position);
            }
        } else if (c instanceof Container) {
            Component[] children = ((Container)c).getComponents();
            for (int i = 0; i < children.length; i++) {
                scrollTextFields(children[i]);
View Full Code Here

                 * On editable text components position the caret to the end of the cust existent
                 * text.
                 */
                if (inFoc instanceof JTextComponent)
                {
                    JTextComponent inText = (JTextComponent) inFoc;
                    if (inText.isEditable() && inText.getDocument() != null)
                    {
                        inText.setCaretPosition(inText.getDocument().getLength());
                    }
                }
            }
            performHeading(panel);
            performHeadingCounter(panel);
View Full Code Here

      System.arraycopy(args, 2, argsShortened, 0, args.length - 2);
      args = argsShortened;
    } else
      args = new String[] {};

    final JTextComponent textarea = editorPane ? new JEditorPane("text/html", "") : new JTextArea();

    final StringBuilder content = new StringBuilder();
    if (editorPane)
      content.append("<html><code>");

    textarea.setEditable(false);
    final JPanel panel = new JPanel(new BorderLayout());

    final JButton buttonPref = new JButton("Preferences");
    buttonPref.addActionListener(new ActionListener() {
      @Override
View Full Code Here

  public static JFrame initJFrame(final String[] args,
      final String preferencesFile, final String title,
      final ActionListener startButtonAction, final JPanel panelNorth,
      final String borderLayoutConstant, final IXPref ixpref) {
    final JTextComponent textarea = editorPane ? new JEditorPane(
        "text/html", "") : new JTextArea();
        final StringBuilder content = new StringBuilder();
        if (editorPane)
          content.append("<html><code>");

        textarea.setEditable(false);

        return initJFrame(args, preferencesFile, title, startButtonAction,
            panelNorth, borderLayoutConstant, textarea, content, ixpref);
  }
View Full Code Here

TOP

Related Classes of javax.swing.text.JTextComponent$CaretEventImpl

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.