1
I have a window with a JTable
, where only an entire row is valid, not just one field. The point is that the window already opens with the first line selected, and I’d like to disable that.
In that very window I have one JButton
which is already disabled at the time of its creation, but I would like to activate it as soon as the user selects any line from JTable
...
Summarizing : How I disable automatic line selection JTable
at the moment the window opens ? How to activate a button when the user selects any row from it JTable
?
@Danielsantos the solution managed to solve his problem?
– user28595
Sorry it took so long to answer ! It solved half of my haha problems. The section that deals with activating the button worked perfectly. The problem is in the
requestFocus()
... I put him in the builder’sJFrame
, and it wasn’t, then I made that same command in the window controller (which is the class that is "called") that way :gridCliente.requestFocus();
and it didn’t work either !– Daniel Santos
@Danielsantos how did it not work? You are not removing the initial focus from the table?
– user28595
Exactly ! The window keeps selecting the first line of the
JTable
at the beginning ...– Daniel Santos
Could you show us the code of your window? Post on Pastebin.com
– user28595
http://pastebin.com/zdP39qAA is there, the same command in both classes !
– Daniel Santos
@Danielsantos You built this entire screen per line of code only or used some screen builder, such as Windows in Eclipse or Netbeans?
– user28595
I built it all, line by line in the eclipse ...
– Daniel Santos
@Danielsantos test with the change I made here http://pastebin.com/T6UKmZzj
– user28595
Not expensive, these objects are of the package
awt
, right ?– Daniel Santos
@Danielsantos actually just added a Thinker to change his focus. Look honestly, without testing all the code it is difficult to figure out the real problem, I did several tests here and in all the focus was changed. As a last attempt, try adding this right after you create your table:
suaTable.getSelectionModel().clearSelection();
– user28595
It wasn’t expensive either, but I appreciate your effort !
– Daniel Santos