currently the JTable cell is selected on first click, and on the second one it is edited.
Is it possible to directly edit it on the first click?
jTableAssignments = new javax. swing. JTable() { public boolean isCellEditable(int rowIndex, int colIndex) { return editable; }};
You can select cells by simulating clicks. To simulate clicks on JTable cells, you can use the ClickCell , ClickCellR , DblClickCell and similar actions of the JTable object. All of these actions have parameters that specify the row and the column that contain the needed cell.
In the DefaultCellEditor api there is a method named setClickCountToStart
DefaultCellEditor singleclick = new DefaultCellEditor(new JTextField());
singleclick.setClickCountToStart(1);
//set the editor as default on every column
for (int i = 0; i < table.getColumnCount(); i++) {
table.setDefaultEditor(table.getColumnClass(i), singleclick);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With