Search in sources :

Example 71 with DocumentEvent

use of javax.swing.event.DocumentEvent in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoSdkConfigurable method listenForPathUpdate.

private void listenForPathUpdate() {
    JTextField textField = mySdkPathField.getTextField();
    Ref<String> prevPathRef = Ref.create(StringUtil.notNullize(textField.getText()));
    textField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            String sdkPath = StringUtil.notNullize(textField.getText());
            String prevPath = prevPathRef.get();
            if (!prevPath.equals(sdkPath)) {
                asyncUpdateSdkVersion(sdkPath);
                prevPathRef.set(sdkPath);
            }
        }
    });
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 72 with DocumentEvent

use of javax.swing.event.DocumentEvent in project libgdx by libgdx.

the class JglfwInput method getTextInput.

public void getTextInput(final TextInputListener listener, final String title, final String text, final String hint) {
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            JPanel panel = new JPanel(new FlowLayout());
            JPanel textPanel = new JPanel() {

                public boolean isOptimizedDrawingEnabled() {
                    return false;
                }

                ;
            };
            textPanel.setLayout(new OverlayLayout(textPanel));
            panel.add(textPanel);
            final JTextField textField = new JTextField(20);
            textField.setText(text);
            textField.setAlignmentX(0.0f);
            textPanel.add(textField);
            final JLabel placeholderLabel = new JLabel(hint);
            placeholderLabel.setForeground(Color.GRAY);
            placeholderLabel.setAlignmentX(0.0f);
            textPanel.add(placeholderLabel, 0);
            textField.getDocument().addDocumentListener(new DocumentListener() {

                public void removeUpdate(DocumentEvent event) {
                    this.updated();
                }

                public void insertUpdate(DocumentEvent event) {
                    this.updated();
                }

                public void changedUpdate(DocumentEvent event) {
                    this.updated();
                }

                private void updated() {
                    placeholderLabel.setVisible(textField.getText().length() == 0);
                }
            });
            JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
            pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation());
            pane.selectInitialValue();
            placeholderLabel.setBorder(new EmptyBorder(textField.getBorder().getBorderInsets(textField)));
            JDialog dialog = pane.createDialog(null, title);
            dialog.addWindowFocusListener(new WindowFocusListener() {

                public void windowLostFocus(WindowEvent arg0) {
                }

                public void windowGainedFocus(WindowEvent arg0) {
                    textField.requestFocusInWindow();
                }
            });
            dialog.setVisible(true);
            dialog.dispose();
            Object selectedValue = pane.getValue();
            if (selectedValue != null && (selectedValue instanceof Integer) && (Integer) selectedValue == JOptionPane.OK_OPTION)
                listener.input(textField.getText());
            else
                listener.canceled();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) FlowLayout(java.awt.FlowLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent) JOptionPane(javax.swing.JOptionPane) WindowEvent(java.awt.event.WindowEvent) OverlayLayout(javax.swing.OverlayLayout) EmptyBorder(javax.swing.border.EmptyBorder) JDialog(javax.swing.JDialog) WindowFocusListener(java.awt.event.WindowFocusListener)

Example 73 with DocumentEvent

use of javax.swing.event.DocumentEvent in project CoreNLP by stanfordnlp.

the class OpenPageDialog method initComponents.

/**
   * This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
private //GEN-BEGIN:initComponents
void initComponents() {
    jPanel1 = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    jPanel3 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    urlTextField = new javax.swing.JTextField();
    jPanel2 = new javax.swing.JPanel();
    openButton = new javax.swing.JButton();
    cancelButton = new javax.swing.JButton();
    browseButton = new javax.swing.JButton();
    addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent evt) {
            closeDialog(evt);
        }
    });
    jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS));
    jLabel2.setText("Type in the internet address of a document or web page.");
    jPanel1.add(jLabel2);
    jLabel1.setText("Open");
    jPanel3.add(jLabel1);
    urlTextField.setMinimumSize(new java.awt.Dimension(100, 20));
    urlTextField.setPreferredSize(new java.awt.Dimension(300, 20));
    urlTextField.getDocument().addDocumentListener(new DocumentListener() {

        public void changedUpdate(DocumentEvent e) {
            enableOpenButton();
        }

        public void insertUpdate(DocumentEvent e) {
            enableOpenButton();
        }

        public void removeUpdate(DocumentEvent e) {
            enableOpenButton();
        }
    });
    urlTextField.addActionListener(evt -> urlTextFieldActionPerformed(evt));
    jPanel3.add(urlTextField);
    jPanel1.add(jPanel3);
    getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
    openButton.setText("Open");
    openButton.setEnabled(false);
    openButton.addActionListener(evt -> openButtonActionPerformed(evt));
    jPanel2.add(openButton);
    cancelButton.setText("Cancel");
    cancelButton.addActionListener(evt -> cancelButtonActionPerformed(evt));
    jPanel2.add(cancelButton);
    browseButton.setText("Browse");
    browseButton.addActionListener(evt -> browseButtonActionPerformed(evt));
    jPanel2.add(browseButton);
    getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
    pack();
}
Also used : DocumentListener(javax.swing.event.DocumentListener) WindowAdapter(java.awt.event.WindowAdapter) DocumentEvent(javax.swing.event.DocumentEvent) WindowEvent(java.awt.event.WindowEvent) javax.swing(javax.swing)

Example 74 with DocumentEvent

use of javax.swing.event.DocumentEvent in project android by JetBrains.

the class TraceViewPanel method createSearchField.

private SearchTextField createSearchField() {
    SearchTextField stf = new SearchTextField(true);
    stf.setOpaque(false);
    stf.setEnabled(true);
    Utils.setSmallerFont(stf);
    stf.addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            searchTextChanged(getText(e));
        }

        private String getText(DocumentEvent e) {
            try {
                return e.getDocument().getText(0, e.getDocument().getLength());
            } catch (BadLocationException e1) {
                return "";
            }
        }
    });
    JTextField editorTextField = stf.getTextEditor();
    editorTextField.setMinimumSize(new Dimension(JBUI.scale(200), -1));
    editorTextField.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            closeSearchComponent();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
    return stf;
}
Also used : SearchTextField(com.intellij.ui.SearchTextField) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) BadLocationException(javax.swing.text.BadLocationException)

Example 75 with DocumentEvent

use of javax.swing.event.DocumentEvent in project android by JetBrains.

the class ImportSourceLocationStep method setupSourceLocationControls.

private void setupSourceLocationControls() {
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor();
    descriptor.setTitle("Select Source Location");
    descriptor.setDescription("Select existing ADT or Gradle project to import as a new subproject");
    mySourceLocation.addBrowseFolderListener(new TextBrowseFolderListener(descriptor));
    mySourceLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            invalidate();
        }
    });
    applyBackgroundOperationResult(checkPath(mySourceLocation.getText()));
    myErrorWarning.setIcon(null);
    myErrorWarning.setText(null);
}
Also used : FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) TextBrowseFolderListener(com.intellij.openapi.ui.TextBrowseFolderListener) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Aggregations

DocumentEvent (javax.swing.event.DocumentEvent)139 DocumentListener (javax.swing.event.DocumentListener)70 DocumentAdapter (com.intellij.ui.DocumentAdapter)64 ActionEvent (java.awt.event.ActionEvent)36 ActionListener (java.awt.event.ActionListener)34 JTextField (javax.swing.JTextField)22 JLabel (javax.swing.JLabel)18 JPanel (javax.swing.JPanel)18 Dimension (java.awt.Dimension)16 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)13 ItemEvent (java.awt.event.ItemEvent)13 ItemListener (java.awt.event.ItemListener)13 ChangeEvent (javax.swing.event.ChangeEvent)13 JButton (javax.swing.JButton)12 JCheckBox (javax.swing.JCheckBox)12 ChangeListener (javax.swing.event.ChangeListener)11 Document (javax.swing.text.Document)10 GridBagLayout (java.awt.GridBagLayout)9 NotNull (org.jetbrains.annotations.NotNull)9 GridBagConstraints (java.awt.GridBagConstraints)8