I am using two JTables. If I click the first table cell, the cell in that table getting focused. After that, if I click the second table, the second table cell getting focused. But the first table also having the focus. How to remove the focus in the first JTable Cell. Help me. Thanks in advance.
How to remove focus from one jtable cell, if I click the another Jtable cell?
2k views Asked by Vishwa Dany At
2
There are 2 answers
0
On
Here's another way, compatible with different kinds of listeners:
//Listener for Table 2
if(table1.isEditing()){ //To prevent Null Pointer Exception
table1.getCellEditor().stopCellEditing();
}
...
//Listener for Table 1
if(table2.isEditing()){ //To prevent Null Pointer Exception
table2.getCellEditor().stopCellEditing();
}
Well on the Table Click event you can get the table Cell which clicked..
try it or jtable cell having by default that behaviour if u use netbeans.