我可以使用鼠标点击将焦点设置为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();
}
}
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
894 次 |
| 最近记录: |