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);
}
}
});
}
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();
}
});
}
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();
}
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;
}
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);
}
Aggregations