Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hi, i'm using some JRadioButton com

Status
Not open for further replies.

vkarthik

Programmer
Aug 30, 2001
126
US
hi, i'm using some JRadioButton components in a program. i added them to a single group using javax.swing.ButtonGroup class's add() method. Inside itemlistener handler, i want to know which radio button was selected. how do i do this? the methods like getState(), getSelection (a method of ButtonGroup) dont work. plz help!!!

luv
Karthik.
 
I hope this works for you...
if(e.getStateChange() == ItemEvent.SELECTED)
notifyObservers((JRadioButton)e.getSource());

private void notifyObservers(JRadioButton rad) {
String RButon_selected = rad.getText();
}

This way you can find out which RButton was selected and then do whatever you wanted to do

Sharad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top