List of usage examples for javax.swing JTextField transferFocus
public void transferFocus()
From source file:Main.java
public static void main(String[] args) { JComboBox<String> comboBox = new JComboBox<>(new String[] { "A", "B", "C" }); comboBox.setEditable(true);// w ww . j a va 2 s . co m JTextField editorComponent = (JTextField) comboBox.getEditor().getEditorComponent(); editorComponent.addActionListener(e -> { editorComponent.transferFocus(); }); JPanel panel = new JPanel(new FlowLayout()); panel.add(new JLabel("Field 1")); panel.add(comboBox); panel.add(new JLabel("Field 2")); panel.add(new JTextField(10)); panel.add(new JLabel("Field 3")); panel.add(new JTextField(10)); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); Container c = frame.getContentPane(); c.setLayout(new BorderLayout()); c.add(panel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }