1
그래서 프레임, 테이블 및 텍스트 필드에 두 개의 구성 요소가 있습니다. 그러나 테이블에 포커스가 있고 탭 키를 누르면 포커스가 텍스트 필드로 이동하지 않습니다. 왜 이런 일이 일어나는거야?탭 키가 JTable의 포커스를 전달할 수 없습니다.
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame();
String[][] data = { { "Data" } };
String[] cols = { "COlo" };
JTable table = new JTable(data, cols);
table.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
System.out.println("focus lost");
}
public void focusGained(FocusEvent arg0) {
System.out.println("gained");
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(table, BorderLayout.NORTH);
frame.add(new JTextField(), BorderLayout.SOUTH);
frame.setVisible(true);
table.requestFocus();
}
});
}
이것은 오래된 기사이지만보고있는 내용에 대한 설명을 제공 할 수 있습니다. https://www.java.net/node/651087. 또한 "JTable focustraversalpolicy"에 대한 StackOverflow 검색을 시도하십시오. – terrywb