Remove focus from first line of JTable

I have a JTable and a string in it. By default, the first row is selected and focus is in it. How can I deselect the first row and change the focus to another, that .addListener(new RowSetListener() will work in the first row .addListener(new RowSetListener() .

I'm already trying:

 tableZaposlenciView1.setRowSelectionAllowed(true); //tableZaposlenciView1.getSelectionModel().clearSelection(); //tableZaposlenciView1.setColumnSelectionInterval(0,0); //tableZaposlenciView1.setRowSelectionInterval(false,false); tableZaposlenciView1.changeSelection(0,0,false,false); tableZaposlenciView1.requestFocus(); 

but it does not work.

+4
source share
2 answers

If anyone has a similar problem with ADF and JTable, this is the solution. I achieve this by first redefining () on the VO impl. my problem can be solved.

This is useful in many situations:

  • no choice after update (just return null from first ())
  • re-select a specific line after updating (before updating, save the key of the line after updating in the first (), if the found key is found, go to this line and return it from first ())
  • find the next appropriate line for the user to work after updating the worklist.
  • Avoid costly executions in a VL situation.
0
source

Take a look at the JTable changeSelection () method. I believe that he does what you want.

EDIT: If you want to remove the selection:

 JTable table = ...; table.getSelectionModel().clearSelection(); 
+2
source

All Articles