How to use the Swing radio button control on a form.
You can run this technique code from:
NOTE First make sure that database is running on your localhost SilverStream Server | |
See the chapter on the Form Designer in the Tools Guide |
The following code uses the getState()
method to determine if a radio button (rbStandardHealth) is currently selected. It then uses setText()
to place a corresponding value in a text label lblRBValue.
This code is for the actionPerformed event of rbStandardHealth.
// If the Standard Health radio button is now selected, // change the label to display the value 'Standard' if (rbStandardHealth.getState()) lblRBValue.setText("Value = Standard");
This code sets the button's value programmatically.
rbStandardHealth.setState(true);
NOTE When the user clicks a radio button, a valueChanged event occurs for all the radio buttons in the group. An actionPerformed event occurs for the clicked button. If a radio button's value changes programmatically, a valueChanged event occurs for all the buttons, even if the value does not actually change (for example, the state of more than one button may remain false).