Reputation: 619
How can I get the focus on a specified row in JTable
i.e if click on first row, first row will get focused, if I click on second row,second row will get focused and so on...
But I need to get the focus on a specified row i.e if I want get the focus on first row, it will only be get focused, the other rows should not be get focus when I clicked on them.
I tried with getTable().requestFocus()
and getTable().changeSelection(1, 1, false, false)
methods but it's not working.
Can anyone please help me? I am new to Java Swing.
Upvotes: 0
Views: 3676
Reputation: 347204
The methods you are looking for are JTable#setRowSelectionInterval and JTable#setColumnSelectionInterval
Upvotes: 3