编辑焦点JPanel在JTable中

时间:2012-03-07 11:08:03

标签: swing focus jtable jpanel

这个问题类似于: Problem getting focus when use JPanel as JTable cell editor

只有我似乎被困了一步。

我有一个自定义的TableCellEditor,它返回一个内部带有JTextField的JPanel(简化案例)。 我希望在选中该表格单元格时编辑JTextField。

我在JTable中有这段代码,以便在选项卡上进行表格编辑:

public void changeSelection(final int row, int column, boolean toggle, boolean extend){
        System.out.println("selectionChanged");
    super.changeSelection(row, column, toggle, extend);
    if (!isCellEditable(row, column))
        return;
    AuthorTableEditor editor = (AuthorTableEditor) getCellEditor(row, column);
    editor.setAutoFocus(this, row, column);
    editCellAt(row, column);
}

使用setAutoFocus,因此AuthorTableEditor中的方法不会被调用两次。

如何编辑JTextField,就像我在TableCellEditor中返回JTextField时会发生什么?

0 个答案:

没有答案