I am developing a GUI application,in that there are 5 radio buttons ysite,admixture,solution,syringe,TPN and ALL in which when i was selected any radio button and enter some textfields and press the enter button it can call corresponding web services methods,Here i implemented the code.
Here is the sample code for radio button
ysite = new StandardRadioButton("Y-Site"); admixture = new StandardRadioButton("Admixture"); solution = new StandardRadioButton("Solution"); syringe = new StandardRadioButton("Syringe"); TPN = new StandardRadioButton("TPN"); all = new StandardRadioButton("All");
String[] admin = {"YSITE","ADMIXTURE","SOLUTION","SYRINGE","TPN","ALL"}; int index = 6;
if(ysite.isSelected()) index = 0; else if(admixture.isSelected()) index = 1; else if(solution.isSelected()) index = 2; else if(syringe.isSelected()) index = 3; else if(TPN.isSelected()) index = 4; else if(all.isSelected())index = 5;
the above logic is correct or wrong to select radiobutton ??
Thank you in advance
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> the above logic is correct or wrong to select radiobutton ??
if it works, it's not 'wrong', but perhaps there's a different way:
when creating the radioButtons (usually in a for loop): set the actionCommand to the index you want add the radioButton to a ButtonGroup
now , when you want the selected index buttonGroup.getSelection().getActionCommand(); which will return a String (the index you supplied in the loop). if you need the index as an int, just parseInt() the String index
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.