我可以使用鼠标单击将焦点设置到 JTable 中的单个单元格,但是当使用选项卡在单元格之间移动时,下一个选定的选项卡单元格似乎只是突出显示,而不是焦点。
有没有办法使用“Tab”键设置单元格的焦点?
最佳答案
重写 JTable 的 changeSelection() 方法:
JTable table = new JTable(...)
{
// Place cell in edit mode when it 'gains focus'
public void changeSelection(
int row, int column, boolean toggle, boolean extend)
{
super.changeSelection(row, column, toggle, extend);
if (editCellAt(row, column))
{
Component editor = getEditorComponent();
editor.requestFocusInWindow();
// ((JTextComponent)editor).selectAll();
}
}
};
关于java - 在 JTable 中使用 "Tab"的 TextArea Focus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7389991/