Results 1 to 4 of 4
Thread: Help help.radio buttons
- 01-04-2011, 06:47 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 33
- Rep Power
- 0
Help help.radio buttons
how to get the value male or female as string from radio button selected by user?code:
private JRadioButton jRadioButtonMale = null;
private JRadioButton jRadioButtonFemale = null;
private ButtonGroup group;
group = new ButtonGroup();
group.add(jRadioButtonMale);
group.add(jRadioButtonFemale);
private JRadioButton getJRadioButtonMale() {
if (jRadioButtonMale == null) {
jRadioButtonMale = new JRadioButton(male);
jRadioButtonMale.setText("Male");
jRadioButtonMale.setSize(new Dimension(80, 20));
jRadioButtonMale.setLocation(new Point(557, 120));
}
return jRadioButtonMale;
}
private JRadioButton getJRadioButtonFemale() {
if (jRadioButtonFemale == null) {
jRadioButtonFemale = new JRadioButton(female);
jRadioButtonFemale.setText("Female");
jRadioButtonFemale.setSize(new Dimension(80, 20));
jRadioButtonFemale.setLocation(new Point(650, 120));
}
return jRadioButtonFemale;
}
how?help pls
- 01-04-2011, 06:53 PM #2
Check which one is selected and return the appropriate value (whether that is a boolean, a String, an enum, or something else is up to you). Where are you getting stuck with that?
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-04-2011, 07:03 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 33
- Rep Power
- 0
when i press the submit button. i do not know my String gender = ???????(dunno the selection of my user)
- 01-04-2011, 07:10 PM #4
JRadioButton has an isSelected() method that will tell you whether it has been selected.
ButtonGroup has a getSelection() method that returns the selected ButtonModel.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Similar Threads
-
Help with Radio Buttons
By miguelms19 in forum AWT / SwingReplies: 3Last Post: 06-29-2010, 07:49 PM -
Radio Buttons and Jtextfield
By ogsirus in forum AWT / SwingReplies: 7Last Post: 05-26-2010, 10:41 PM -
Displaying Radio Buttons in JSP
By kishan in forum Advanced JavaReplies: 4Last Post: 10-23-2009, 03:44 PM -
How to use Radio Buttons
By Java Tip in forum SWTReplies: 0Last Post: 07-25-2008, 02:26 PM -
radio buttons and paint
By gtraylo in forum Java AppletsReplies: 1Last Post: 04-19-2008, 12:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks