List of utility methods to do JTextField Focus
JTextField | _createJTextField(String name, FocusListener fl) create J Text Field JTextField jt = new JTextField(); jt.setName(name); jt.addFocusListener(fl); return jt; |
void | addListenerToCommitOnFocusLost(final JTextField field) Add Focus listener to text field to commit field whenever it loses focus. field.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { field.postActionEvent(); }); |
void | addNewFocusListenerForTextField(final JTextField textField, final Runnable r) add New Focus Listener For Text Field textField.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent arg0) { r.run(); @Override public void focusGained(final FocusEvent arg0) { textField.selectAll(); ... |
void | attachListenerOnLabelClickFocusTextElement(JLabel label, final JTextField textField) Attaches a listener to the specified label that directs the focus to the supplied text (resulting in an HTML form-like connection of the label and its input field). label.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { focusAccompanyingInput(); @Override public void mousePressed(MouseEvent e) { focusAccompanyingInput(); ... |
void | clearOnFocus(final JTextField jtf, final String onlyInText) clear On Focus jtf.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { if (onlyInText != null) { if (jtf.getText().equals(onlyInText)) { jtf.setText(""); } else { ... |
void | configureFocusActionKeys(JTextField textField, boolean primary) configure Focus Action Keys if (!primary) { textField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), JTextField.notifyAction); textField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JTextField.notifyAction); textField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET); textField.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { ... |
void | makeSureUserGetsFocus(final JTextField field) Forces focus to a particular JTextField in a displayed dialog field.addHierarchyListener(new HierarchyListener() { HierarchyListener hierarchyListener = this; @Override public void hierarchyChanged(HierarchyEvent e) { JRootPane rootPane = SwingUtilities.getRootPane(field); if (rootPane != null) { final JButton okButton = rootPane.getDefaultButton(); if (okButton != null) { ... |
boolean | minimoCaracteres(JTextField txt, FocusEvent e, int pValor) minimo Caracteres if (txt.getText().length() <= pValor) { return true; return false; |