use of javax.swing.event.DocumentListener in project gradle by gradle.
the class SearchPanel method createTextToMatchField.
private Component createTextToMatchField() {
textToMatchField = new JTextField();
textToMatchField.setMinimumSize(new Dimension(50, 10));
//escape closes this dialog
textToMatchField.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
hide();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
//hook up the key strokes that perform the search
ActionListener performSearchNextAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
goToNextMatch();
}
};
//hook up the key strokes that perform the search
ActionListener performSearchPreviousAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
goToPreviousMatch();
}
};
textToMatchField.registerKeyboardAction(performSearchNextAction, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
//F3 and Shift F3
textToMatchField.registerKeyboardAction(performSearchNextAction, KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
textToMatchField.registerKeyboardAction(performSearchPreviousAction, KeyStroke.getKeyStroke(KeyEvent.VK_F3, KeyEvent.SHIFT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
//as the user types, perform a 'continue' search.
textToMatchField.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
requestSearch();
}
public void removeUpdate(DocumentEvent e) {
requestSearch();
}
public void changedUpdate(DocumentEvent e) {
requestSearch();
}
});
return textToMatchField;
}
use of javax.swing.event.DocumentListener in project gradle by gradle.
the class SwingEditFavoriteInteraction method createMainPanel.
private Component createMainPanel() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
fullCommandLineTextField = new JTextField();
displayNameTextField = new JTextField();
alwaysShowOutputCheckBox = new JCheckBox("Always Show Live Output");
panel.add(Utility.addLeftJustifiedComponent(new JLabel("Command Line")));
panel.add(Utility.addLeftJustifiedComponent(fullCommandLineTextField));
panel.add(Box.createVerticalStrut(10));
panel.add(Utility.addLeftJustifiedComponent(new JLabel("Display Name")));
panel.add(Utility.addLeftJustifiedComponent(displayNameTextField));
panel.add(Box.createVerticalStrut(10));
panel.add(Utility.addLeftJustifiedComponent(alwaysShowOutputCheckBox));
panel.add(Box.createVerticalGlue());
//create some listeners that we can use for synchronization purposes.
synchronizationDocumentListener = new DocumentListener() {
public void insertUpdate(DocumentEvent documentEvent) {
setDisplayNameTextToCommandLineText();
}
public void removeUpdate(DocumentEvent documentEvent) {
setDisplayNameTextToCommandLineText();
}
public void changedUpdate(DocumentEvent documentEvent) {
setDisplayNameTextToCommandLineText();
}
};
synchronizationKeyAdapter = new KeyAdapter() {
@Override
public void keyPressed(KeyEvent keyEvent) {
//the user typed something. Remove the document listener
fullCommandLineTextField.getDocument().removeDocumentListener(synchronizationDocumentListener);
//and we don't need this anymore either
displayNameTextField.removeKeyListener(synchronizationKeyAdapter);
}
};
return panel;
}
use of javax.swing.event.DocumentListener in project zaproxy by zaproxy.
the class ManageAddOnsDialog method createFilterPanel.
private static JPanel createFilterPanel(final JXTable table) {
JPanel filterPanel = new JPanel();
filterPanel.setLayout(new GridBagLayout());
JLabel filterLabel = new JLabel(Constant.messages.getString("cfu.label.addons.filter"));
final JTextField filterTextField = new JTextField();
filterLabel.setLabelFor(filterTextField);
filterPanel.add(filterLabel, LayoutHelper.getGBC(0, 0, 1, 0.0D));
filterPanel.add(filterTextField, LayoutHelper.getGBC(1, 0, 1, 1.0D));
String tooltipText = Constant.messages.getString("cfu.label.addons.filter.tooltip");
filterLabel.setToolTipText(tooltipText);
filterTextField.setToolTipText(tooltipText);
// Set filter listener
filterTextField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
updateFilter();
}
@Override
public void removeUpdate(DocumentEvent e) {
updateFilter();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateFilter();
}
public void updateFilter() {
String filterText = filterTextField.getText();
if (filterText.isEmpty()) {
table.setRowFilter(null);
filterTextField.setForeground(UIManager.getColor("TextField.foreground"));
} else {
try {
table.setRowFilter(RowFilter.regexFilter("(?i)" + filterText));
filterTextField.setForeground(UIManager.getColor("TextField.foreground"));
} catch (PatternSyntaxException e) {
filterTextField.setForeground(Color.RED);
}
}
}
});
return filterPanel;
}
use of javax.swing.event.DocumentListener in project zaproxy by zaproxy.
the class DialogAddToken method getRegexTextField.
protected ZapTextField getRegexTextField() {
if (regexTextField == null) {
regexTextField = new ZapTextField(25);
regexTextField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
checkAndEnableConfirmButton();
}
@Override
public void insertUpdate(DocumentEvent e) {
checkAndEnableConfirmButton();
}
@Override
public void changedUpdate(DocumentEvent e) {
checkAndEnableConfirmButton();
}
private void checkAndEnableConfirmButton() {
setConfirmButtonEnabled(getRegexTextField().getDocument().getLength() > 0);
}
});
}
return regexTextField;
}
use of javax.swing.event.DocumentListener in project zaproxy by zaproxy.
the class EncodeDecodeDialog method getInputField.
private ZapTextArea getInputField() {
if (inputField == null) {
inputField = newField(true);
inputField.setName(ENCODE_DECODE_FIELD);
inputField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent documentEvent) {
updateEncodeDecodeFields();
}
@Override
public void removeUpdate(DocumentEvent documentEvent) {
updateEncodeDecodeFields();
}
@Override
public void changedUpdate(DocumentEvent documentEvent) {
}
});
inputField.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mousePressed(java.awt.event.MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
}
}
});
}
return inputField;
}
Aggregations