| Author |
How to make a check on a radio button in Java code without using the Mouse
|
Tomas Reyes
Greenhorn
Joined: Jan 12, 2011
Posts: 6
|
|
I created a JTable and add a radio button. After I created another JTable when I click on the string of one row
I have to select and check on the radio button of the initial JTable, and found the radio button but I am not
shure what property or method allows me to check the radio button without using the mouse.
My code is:
Thanks in advance
Tomas
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Check out the setSelected method.
Note that calling setSelected(false) will not uncheck a radio button. To do that, the usual trick is to add a radio button to the same button group but not add it to the user interface. When you select this invisible radio button all other radio buttons are unselected.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4167
|
|
|
... or call clearSelection() of the ButtonGroup.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Darryl Burke wrote:... or call clearSelection() of the ButtonGroup.
Cool, this method was really needed. I didn't know they added it in Java 6.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4167
|
|
Rob Spoor wrote:
Darryl Burke wrote:... or call clearSelection() of the ButtonGroup.
Cool, this method was really needed. I didn't know they added it in Java 6.
I only came to Java after 6 was released, so it's maybe easier for me ;)
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
|
There are 4072 (I think) classes in Java7, and some have hundreds of methods, so you can’t expect people to know about every method.
|
 |
Tomas Reyes
Greenhorn
Joined: Jan 12, 2011
Posts: 6
|
|
But how to specify the selected row in the setSelected is something like:
|
 |
 |
|
|
subject: How to make a check on a radio button in Java code without using the Mouse
|
|
|