javaswingtablecelleditorjide

Best Practice for Cell Editing (Single-Click or Double-Click) in Table in Swing


I want to ask some questions regarding editing cell in a table.

Currently my practices of doing cell editing in a table is by double-clicking the cell to make the cell editable for text input. For the single-clicking, it will select the row instead. It just like Excel behaviour of cell editing. What I see in some of JIDE demo , some of the table can be editable using single-click such as "EditableTableHeaderDemo" and some of it can be editable using double-clicking such as JideTableDemo.

What I want to know here is the best practices of cell editing in a table whether it is single-click or double-click? Is there any issue if we use double-click to edit the table compared to the single-click to edit the table? In terms of user friendliness,usability and human computer interaction, which one is better?


Solution

  • Many users prefer a key binding. F2 is a common (but not universal) default; Enter also has some appeal. Also consider making the choice part of your java.util.Preferences, mentioned here.

    table.getInputMap().put(
        KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "startEditing");