Java - how do I gain focus on JTextArea when selecting a new JTabbedPane
问题 I have a swing GUI with multiple JTabbedPane s; each tab contains two JButtons at the top, then a JTextArea (for user input), and a JTextField at the bottom for a result. My problem is that I can't get the JTextArea to gain focus after switching tabs without either clicking in it with the mouse or using the tab key on the keyboard? I have... frame.addWindowFocusListener(new WindowAdapter() { public void windowGainedFocus(WindowEvent e) { textArea_1.requestFocusInWindow(); ...and this works