+ drawBox(0, 0, getWidth(), getHeight(), radioGroupColor, radioGroupColor,
+ 3, false);
+
+ hLineXY(1, 0, StringUtils.width(label) + 2, ' ', radioGroupColor);
+ 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. 1-based.
+ *
+ * @param id ID of the selected button, or 0 to unselect
+ */
+ public void setSelected(final int id) {
+ if ((id < 0) || (id > getChildren().size())) {
+ return;
+ }
+
+ for (TWidget widget: getChildren()) {
+ ((TRadioButton) widget).selected = false;
+ }
+ if (id == 0) {
+ selectedButton = null;
+ return;
+ }
+ assert ((id > 0) && (id <= getChildren().size()));
+ TRadioButton button = (TRadioButton) (getChildren().get(id - 1));
+ button.selected = true;
+ selectedButton = button;
+ }
+
+ /**
+ * Get the radio button that was selected.
+ *
+ * @return the selected button, or null if no button is selected
+ */
+ public TRadioButton getSelectedButton() {
+ return selectedButton;
+ }
+
+ /**
+ * Convenience function to add a radio button to this group.
+ *
+ * @param label label to display next to (right of) the radiobutton
+ * @param selected if true, this will be the selected radiobutton
+ * @return the new radio button
+ */
+ public TRadioButton addRadioButton(final String label,
+ final boolean selected) {