+ return new TRadioButton(this, 0, 0, label, 0);
+ }
+
+ /**
+ * Package private method for RadioButton to add itself to a RadioGroup
+ * container.
+ *
+ * @param button the button to add
+ */
+ void addRadioButton(final TRadioButton button) {
+ super.setHeight(getChildren().size() + 2);
+ button.setX(1);
+ button.setY(getChildren().size());
+ button.id = getChildren().size();
+ String label = button.getMnemonic().getRawLabel();
+
+ if (StringUtils.width(label) + 4 > getWidth()) {
+ super.setWidth(StringUtils.width(label) + 7);
+ }
+
+ if (getParent().getLayoutManager() != null) {
+ getParent().getLayoutManager().resetSize(this);
+ }
+
+ // Default to the first item on the list.
+ activate(getChildren().get(0));
+ }
+
+ /**
+ * Get the requires selection flag.
+ *
+ * @return true if this radiogroup requires that one of the buttons be
+ * selected
+ */
+ public boolean getRequiresSelection() {
+ return requiresSelection;
+ }
+
+ /**
+ * Set the requires selection flag.
+ *
+ * @param requiresSelection if true, then this radiogroup requires that
+ * one of the buttons be selected
+ */
+ public void setRequiresSelection(final boolean requiresSelection) {
+ this.requiresSelection = requiresSelection;
+ if (requiresSelection) {
+ if ((getChildren().size() > 0) && (selectedButton == null)) {
+ setSelected(1);
+ }