List of utility methods to do JTextField
void | setValue(JTextField f, String value) For a JTextField, sets the value, validates, and repaints f.setText(value); f.validate(); f.repaint(); |
File | showFileOpenDialogAndChangePrefs(String prefName, FileNameExtensionFilter fileNameExtensionFilter, JTextField textField, Class forClass, Component parent) displays a file open dialog and copies the result to an edit field JFileChooser fc = new JFileChooser(); fc.setFileFilter(fileNameExtensionFilter); Preferences prefs2 = Preferences.userNodeForPackage(forClass); String path = prefs2.get(prefName, null); if (path != null) { fc.setCurrentDirectory(new File(path)); int result = fc.showOpenDialog(parent); ... |
void | textAreaChangeListener(JTextField a, final ChangeListener list) Reroute all document changes to a change listener a.getDocument().addDocumentListener(new DocumentListener() { public void change() { list.stateChanged(null); public void changedUpdate(DocumentEvent e) { change(); public void removeUpdate(DocumentEvent e) { ... |
void | toUpperCase(JTextField field) to Upper Case String upper = field.getText(); field.setText(upper.toUpperCase()); |
void | triggerTextField(JTextField textField, JCheckBox checkBox) trigger Text Field if (checkBox.isSelected()) {
textField.setDisabledTextColor(Color.LIGHT_GRAY);
textField.setEnabled(!checkBox.isSelected());
|
String | upperText(JTextField text) upper Text String str = text.getText().toUpperCase();
text.setText(str);
return str;
|
double | validateJTextField(JTextField text, Component aThis) Validates if the text field contains a number try { double dev = validateValue(text.getText(), aThis); return dev; } catch (NumberFormatException ex) { text.setText(null); throw ex; |