List of usage examples for javax.swing JTextField getActionListeners
@BeanProperty(bound = false) public synchronized ActionListener[] getActionListeners()
ActionListener
s added to this JTextField with addActionListener(). From source file:Main.java
/** * Programmatically perform action on textfield.This does the same * thing as if the user had pressed enter key in textfield. * * @param textField textField on which action to be preformed *///w w w . j a v a 2 s . com public static void doAction(JTextField textField) { String command = null; if (textField.getAction() != null) command = (String) textField.getAction().getValue(Action.ACTION_COMMAND_KEY); ActionEvent event = null; for (ActionListener listener : textField.getActionListeners()) { if (event == null) event = new ActionEvent(textField, ActionEvent.ACTION_PERFORMED, command, System.currentTimeMillis(), 0); listener.actionPerformed(event); } }