use of java.awt.event.FocusAdapter in project n2a by frothga.
the class SettingsGeneral method addField.
public JPanel addField(final String key, String description, int width, String defaultValue) {
JLabel label = new JLabel(description);
String value = AppData.state.getOrDefault("General", key, defaultValue);
final JTextField field = new JTextField(value, width);
field.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
AppData.state.set("General", key, field.getText());
}
});
field.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
AppData.state.set("General", key, field.getText());
}
});
return Lay.FL("H", label, field);
}
use of java.awt.event.FocusAdapter in project n2a by frothga.
the class Lay method tx.
public static JTextField tx(Object text, Object... args) {
HintList hints = new HintList();
for (Object arg : args) {
if (arg instanceof String) {
hints.addHints(parseHints((String) arg));
}
}
final JTextField txt = new JTextField("" + text);
if (hints.contains("selectall")) {
txt.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
txt.selectAll();
}
});
}
setHints(txt, hints);
return txt;
}
use of java.awt.event.FocusAdapter in project knime-core by knime.
the class VariableFileReaderNodeDialog method createFileNamePanel.
private JPanel createFileNamePanel() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Select variable holding file location: (press 'Enter' to " + "update preview)"));
Box fileBox = Box.createHorizontalBox();
// Creating the brows button here in order to get its preferred height
int buttonHeight = 20;
m_urlCombo = new JComboBox();
m_urlCombo.setEditable(false);
m_urlCombo.setRenderer(new FlowVariableListCellRenderer());
m_urlCombo.setMaximumSize(new Dimension(PANEL_WIDTH, buttonHeight));
m_urlCombo.setMinimumSize(new Dimension(350, buttonHeight));
m_urlCombo.setPreferredSize(new Dimension(350, buttonHeight));
fileBox.add(Box.createHorizontalGlue());
fileBox.add(new JLabel("Flow Variable Name:"));
fileBox.add(Box.createHorizontalStrut(HORIZ_SPACE));
fileBox.add(m_urlCombo);
fileBox.add(Box.createVerticalStrut(50));
fileBox.add(Box.createHorizontalGlue());
// the checkbox for preserving the current settings on file change
Box preserveBox = Box.createHorizontalBox();
m_preserveSettings = new JCheckBox("Preserve user settings for new location");
m_preserveSettings.setToolTipText("if not checked, the settings you" + " have set are reset, if a new location is entered");
m_preserveSettings.setSelected(false);
m_preserveSettings.setEnabled(true);
preserveBox.add(Box.createHorizontalGlue());
preserveBox.add(m_preserveSettings);
preserveBox.add(Box.createHorizontalGlue());
panel.add(fileBox);
panel.add(preserveBox);
panel.setMaximumSize(new Dimension(PANEL_WIDTH, 70));
panel.setMinimumSize(new Dimension(PANEL_WIDTH, 70));
m_urlCombo.addItemListener(this);
/* install action listeners */
// set stuff to update preview when file location changes
m_urlCombo.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(final FocusEvent e) {
fileLocationChanged();
}
});
return panel;
}
Aggregations