// Create an action for each radio button
Action action1 = new AbstractAction("RadioButton Label1") {
// This method is called whenever the radio button is pressed,
// even if it is already selected; this method is not called
// if the radio button was selected programmatically
public void actionPerformed(ActionEvent evt) {
// Perform action
}
};
Action action2 = new AbstractAction("RadioButton Label2") {
// See above
public void actionPerformed(ActionEvent evt) {
// Perform action
}
};
// Create the radio buttons using the actions
JRadioButton b1 = new JRadioButton(action1);
JRadioButton b2 = new JRadioButton(action2);
// Associate the two buttons with a button group
ButtonGroup group = new ButtonGroup();
group.add(b1);
group.add(b2);
Creating a JRadioButton ComponentCreating a JRadioButton Component
Page 1 of 1
1 Replies - 1295 Views - Last Post: 27 September 2005 - 10:10 AM
Replies To: Creating a JRadioButton Component
#2
Re: Creating a JRadioButton Component
Posted 27 September 2005 - 10:10 AM
I'm not sure if you had a question about this or if you're just sharing it. If you're just sharing it, as I said in the email I just sent you, it would be best to put submit it as a "Code Snippet".
You can do that here: http://code.dreamincode.net
If you have a question about this code, please let us know and we'd be happy to help.
You can do that here: http://code.dreamincode.net
If you have a question about this code, please let us know and we'd be happy to help.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|