X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTRadioGroup.java;h=6e6f39d22ad0f955f4b78bd3c9ffa140077828e3;hb=615a0d99fd0aa4437116dd083147f9150d5e6527;hp=20a1ccd468ba5f33259e9788f1db3d6ef45e7287;hpb=e16dda65585466c8987bd1efd718431450a96605;p=fanfix.git diff --git a/src/jexer/TRadioGroup.java b/src/jexer/TRadioGroup.java index 20a1ccd..6e6f39d 100644 --- a/src/jexer/TRadioGroup.java +++ b/src/jexer/TRadioGroup.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2016 Kevin Lamonte + * Copyright (C) 2017 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -33,7 +33,11 @@ import jexer.bits.CellAttributes; /** * 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. @@ -45,30 +49,9 @@ public final 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 final class TRadioGroup extends TWidget { this.label = label; } + // ------------------------------------------------------------------------ + // TWidget ---------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Draw a radio button with label. */ @@ -107,6 +94,35 @@ public final 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. *