X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTRadioGroup.java;h=6e6f39d22ad0f955f4b78bd3c9ffa140077828e3;hb=615a0d99fd0aa4437116dd083147f9150d5e6527;hp=d811f273a56c6a6fc6d62b9a516701d2c894f55a;hpb=7d922e0dfd9a6da42b84e01d52adeec6fff10025;p=nikiroo-utils.git diff --git a/src/jexer/TRadioGroup.java b/src/jexer/TRadioGroup.java index d811f27..6e6f39d 100644 --- a/src/jexer/TRadioGroup.java +++ b/src/jexer/TRadioGroup.java @@ -35,6 +35,10 @@ import jexer.bits.CellAttributes; */ public class TRadioGroup extends TWidget { + // ------------------------------------------------------------------------ + // Variables -------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Label for this radio button group. */ @@ -45,30 +49,9 @@ public class TRadioGroup extends TWidget { */ 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. @@ -87,6 +70,10 @@ public class TRadioGroup extends TWidget { this.label = label; } + // ------------------------------------------------------------------------ + // TWidget ---------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Draw a radio button with label. */ @@ -107,6 +94,35 @@ public class TRadioGroup extends TWidget { 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. *