| java.lang.Object thinwire.ui.AbstractComponent thinwire.ui.AbstractTextComponent thinwire.ui.RadioButton
RadioButton | public class RadioButton extends AbstractTextComponent implements CheckedComponent(Code) | | A RadioButton is a screen element that usually appears in groups. Radio buttons can be either checked or cleared, but only one
radio button per group may be checked.
Example:
final RadioButton rb1 = new RadioButton("Yes");
rb1.setBounds(20, 20, 70, 30);
final RadioButton rb2 = new RadioButton("No");
rb2.setBounds(100, 20, 70, 30);
RadioButton.Group rbg = new RadioButton.Group();
rbg.add(rb1);
rbg.add(rb2);
rbg.addPropertyChangeListener(RadioButton.PROPERTY_CHECKED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent pce) {
RadioButton rb = (RadioButton) pce.getSource();
if (rb == rb1) {
rb.setText(rb.isChecked() ? "[YES]" : "Yes");
} else {
rb.setText(rb.isChecked() ? "[NO]" : "No");
}
}
});
Frame f = Application.current().getFrame();
f.getChildren().add(rb1);
f.getChildren().add(rb2);
Keyboard Navigation:
KEY |
RESPONSE |
NOTE |
Space |
Fires PropertyChangeEvent( propertyName = RadioButton.PROPERTY_CHECKED ) |
Only if the component has focus. |
author: Joshua J. Gertzen |
Inner Class :public static class Group extends AbstractList | |
Constructor Summary | |
public | RadioButton() Constructs a RadioButton with no text. | public | RadioButton(String text) Constructs a RadioButton with the specified text. | public | RadioButton(String text, boolean checked) Constructs a new RadioButton with the specified text and initial checked state. | public | RadioButton(RadioButton.Group group, String text) Constructs a new RadioButton with the specified text, false checked state and group. | public | RadioButton(RadioButton.Group group, String text, boolean checked) Constructs a new RadioButton with the specified text, initial checked state and group. | public | RadioButton(RadioButton sibling, String text) Constructs a new RadioButton with the specified text, false checked state and group.
Parameters: sibling - a RadioButton that has a group this RadioButton should become a member of. | public | RadioButton(RadioButton sibling, String text, boolean checked) Constructs a new RadioButton with the specified text, initial checked state and group.
NOTE: If the specified sibling is not a member of a RadioButton.Group
then a RadioButton.Group will be constructed and both the sibling and this
RadioButton will be added to it.
Parameters: sibling - a RadioButton that has a group this RadioButton should become a member of. |
Method Summary | |
public Group | getGroup() Returns the Group that this radio button is a part of. | public boolean | isChecked() | public void | setChecked(boolean checked) |
PROPERTY_GROUP | final public static String PROPERTY_GROUP(Code) | | |
RadioButton | public RadioButton()(Code) | | Constructs a RadioButton with no text.
|
RadioButton | public RadioButton(String text)(Code) | | Constructs a RadioButton with the specified text.
Parameters: text - the text |
RadioButton | public RadioButton(String text, boolean checked)(Code) | | Constructs a new RadioButton with the specified text and initial checked state.
Parameters: text - the text to display on the right side of the RadioButton. Parameters: checked - the initial checked state |
RadioButton | public RadioButton(RadioButton.Group group, String text)(Code) | | Constructs a new RadioButton with the specified text, false checked state and group.
Parameters: group - the RadioButton.Group for the RadioButton Parameters: text - the text to display on the right side of the RadioButton. throws: IllegalArgumentException - if group is null |
RadioButton | public RadioButton(RadioButton.Group group, String text, boolean checked)(Code) | | Constructs a new RadioButton with the specified text, initial checked state and group.
Parameters: group - the RadioButton.Group for the RadioButton Parameters: text - the text to display on the right side of the RadioButton. Parameters: checked - the initial checked state throws: IllegalArgumentException - if group is null |
RadioButton | public RadioButton(RadioButton sibling, String text)(Code) | | Constructs a new RadioButton with the specified text, false checked state and group.
Parameters: sibling - a RadioButton that has a group this RadioButton should become a member of. Parameters: text - the text to display on the right side of the RadioButton. throws: IllegalArgumentException - if sibling is null |
RadioButton | public RadioButton(RadioButton sibling, String text, boolean checked)(Code) | | Constructs a new RadioButton with the specified text, initial checked state and group.
NOTE: If the specified sibling is not a member of a RadioButton.Group
then a RadioButton.Group will be constructed and both the sibling and this
RadioButton will be added to it.
Parameters: sibling - a RadioButton that has a group this RadioButton should become a member of. Parameters: text - the text to display on the right side of the RadioButton. Parameters: checked - the initial checked state throws: IllegalArgumentException - if sibling is null |
getGroup | public Group getGroup()(Code) | | Returns the Group that this radio button is a part of.
a radio button Group |
isChecked | public boolean isChecked()(Code) | | |
setChecked | public void setChecked(boolean checked)(Code) | | |
Methods inherited from thinwire.ui.AbstractComponent | public void addActionListener(String action, ActionListener listener)(Code)(Java Doc) public void addActionListener(String[] actions, ActionListener listener)(Code)(Java Doc) public void addDropListener(Component dragComponent, DropListener listener)(Code)(Java Doc) public void addDropListener(Component[] dragComponents, DropListener listener)(Code)(Java Doc) public void addKeyPressListener(String keyPressCombo, KeyPressListener listener)(Code)(Java Doc) public void addKeyPressListener(String[] keyPressCombos, KeyPressListener listener)(Code)(Java Doc) public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)(Code)(Java Doc) public void addPropertyChangeListener(String[] propertyNames, PropertyChangeListener listener)(Code)(Java Doc) public void fireAction(ActionEvent ev)(Code)(Java Doc) public void fireAction(String action)(Code)(Java Doc) public void fireAction(String action, Object source)(Code)(Java Doc) public void fireDrop(DropEvent ev)(Code)(Java Doc) public void fireDrop(Component dragComponent)(Code)(Java Doc) public void fireDrop(Component dragComponent, Object dragObject)(Code)(Java Doc) public void fireKeyPress(KeyPressEvent ev)(Code)(Java Doc) public void fireKeyPress(String keyPressCombo)(Code)(Java Doc) final protected boolean firePropertyChange(Object source, String propertyName, int oldValue, int newValue)(Code)(Java Doc) final protected boolean firePropertyChange(Object source, String propertyName, boolean oldValue, boolean newValue)(Code)(Java Doc) final protected boolean firePropertyChange(Object source, String propertyName, Object oldValue, Object newValue)(Code)(Java Doc) public Container getContainer()(Code)(Java Doc) public int getHeight()(Code)(Java Doc) public Label getLabel()(Code)(Java Doc) public Object getLimit()(Code)(Java Doc) public Object getParent()(Code)(Java Doc) String getStandardPropertyUnsupportedMsg(String propertyName, boolean read)(Code)(Java Doc) public Style getStyle()(Code)(Java Doc) public Object getUserObject()(Code)(Java Doc) public int getWidth()(Code)(Java Doc) public int getX()(Code)(Java Doc) public int getY()(Code)(Java Doc) public boolean isEnabled()(Code)(Java Doc) final public boolean isFocus()(Code)(Java Doc) public boolean isFocusCapable()(Code)(Java Doc) public boolean isVisible()(Code)(Java Doc) public void removeActionListener(ActionListener listener)(Code)(Java Doc) public void removeDropListener(DropListener listener)(Code)(Java Doc) public void removeKeyPressListener(KeyPressListener listener)(Code)(Java Doc) public void removePropertyChangeListener(PropertyChangeListener listener)(Code)(Java Doc) public Component setBounds(int x, int y, int width, int height)(Code)(Java Doc) public void setEnabled(boolean enabled)(Code)(Java Doc) public void setFocus(boolean focus)(Code)(Java Doc) public void setFocusCapable(boolean focusCapable)(Code)(Java Doc) public void setHeight(int height)(Code)(Java Doc) void setLabel(Label label)(Code)(Java Doc) public Component setLimit(Object limit)(Code)(Java Doc) void setParent(Object parent)(Code)(Java Doc) public Component setPosition(int x, int y)(Code)(Java Doc) void setRenderer(Renderer r)(Code)(Java Doc) public Component setSize(int width, int height)(Code)(Java Doc) public void setUserObject(Object userObject)(Code)(Java Doc) public void setVisible(boolean visible)(Code)(Java Doc) public void setWidth(int width)(Code)(Java Doc) public void setX(int x)(Code)(Java Doc) public void setY(int y)(Code)(Java Doc)
|
|
|