TextArea使用JTable中的"Tab"进行聚焦

Aka*_*ash 5 java swing jtable

我可以使用鼠标点击将焦点设置为JTable中的单个单元格,但是当使用选项卡在单元格之间移动时,下一个选定的选项卡单元格似乎突出显示,而不是聚焦.

有没有办法使用"Tab"键设置单元格的焦点?

cam*_*ckr 4

重写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)