Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the focused cell in JTable during multiple selection

Tags:

java

swing

jtable

I have a JTable with 10 rows. If I have multiple selections on the JTable, how do I get the cell that is currently focused?

I have tried to used JTable's getEditingColumn() and getEditingRow(), but they always return -1 during multiple selection.

like image 452
doku Avatar asked Feb 03 '23 22:02

doku


1 Answers

The commands;

table.getSelectionModel().getLeadSelectionIndex();
table.getColumnModel().getSelectionModel().getLeadSelectionIndex();

give the selected row and column respectively.

like image 82
Toaster Avatar answered Feb 05 '23 16:02

Toaster