/**
* TRadioGroup is a collection of TRadioButtons with a box and label.
*/
-public final class TRadioGroup extends TWidget {
+public class TRadioGroup extends TWidget {
+
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
* Label for this radio button group.
*/
private TRadioButton selectedButton = null;
- /**
- * Get the radio button ID that was selected.
- *
- * @return ID of the selected button, or 0 if no button is selected
- */
- public int getSelected() {
- if (selectedButton == null) {
- return 0;
- }
- return selectedButton.getId();
- }
-
- /**
- * Set the new selected radio button. Note package private access.
- *
- * @param button new button that became selected
- */
- void setSelected(final TRadioButton button) {
- assert (button.isSelected());
- if (selectedButton != null) {
- selectedButton.setSelected(false);
- }
- selectedButton = button;
- }
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
* Public constructor.
this.label = label;
}
+ // ------------------------------------------------------------------------
+ // TWidget ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Draw a radio button with label.
*/
getScreen().putStringXY(2, 0, label, radioGroupColor);
}
+ // ------------------------------------------------------------------------
+ // TRadioGroup ------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get the radio button ID that was selected.
+ *
+ * @return ID of the selected button, or 0 if no button is selected
+ */
+ public int getSelected() {
+ if (selectedButton == null) {
+ return 0;
+ }
+ return selectedButton.getId();
+ }
+
+ /**
+ * Set the new selected radio button. Note package private access.
+ *
+ * @param button new button that became selected
+ */
+ void setSelected(final TRadioButton button) {
+ assert (button.isSelected());
+ if (selectedButton != null) {
+ selectedButton.setSelected(false);
+ }
+ selectedButton = button;
+ }
+
/**
* Convenience function to add a radio button to this group.
*