Package totalcross.ui

Class RadioGroupController


  • public class RadioGroupController
    extends java.lang.Object
    RadioGroupController is a Radio control grouper. It handles the click on a radio, unchecking the last selected one.

    Use it as:

     RadioGroupController rg = new RadioGroupController();
     Radio r1 = new Radio("radio 1",rg);
     Radio r2 = new Radio("radio 2",rg);
     Radio r3 = new Radio("radio 3",rg);
     rg.setSelectedItem(r1); // activate r1 only
     
    Note: there is no need (and you can't) add a RadioGroupController to a container, since a RadioGroupController is a class that doesn't extend Control.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean sendPressOnLast
      Set to false to disable sending PRESSED events to the previous control.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(Radio newMember)
      Adds a new Radio to the list of Radios this controller handles.
      Radio getRadio​(int idx)
      Returns the Radio at the given index.
      int getSelectedIndex()
      Returns the currently selected index (in the order that the Radios were added to the container), or -1 if none.
      Radio getSelectedItem()
      Returns the currently selected Radio, or null if none.
      int getSize()
      Returns the number of Radio's.
      void remove​(Radio oldMember)
      Removes the given Radio from the list of Radios this controller handles.
      void setSelectedIndex​(int i)
      Selects the given radio and deselects the other one.
      void setSelectedIndex​(int i, boolean sendPressEvent)
      Selects the given radio and deselects the other one.
      void setSelectedItem​(java.lang.String text)
      Selects a radio whose text matches the given caption
      void setSelectedItem​(Radio who)
      Called by the Radio when a click was made
      protected void setSelectedItem​(Radio who, boolean checked)  
      void setSelectedItemStartingWith​(java.lang.String text, boolean caseInsensitive)
      Selects a radio whose text starts with the given caption
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sendPressOnLast

        public boolean sendPressOnLast
        Set to false to disable sending PRESSED events to the previous control.
    • Constructor Detail

      • RadioGroupController

        public RadioGroupController()
    • Method Detail

      • add

        public void add​(Radio newMember)
        Adds a new Radio to the list of Radios this controller handles. This method is called by the Radio's constructor.
      • remove

        public void remove​(Radio oldMember)
        Removes the given Radio from the list of Radios this controller handles. You must explicitly call this method, if needed.
      • setSelectedItem

        public void setSelectedItem​(Radio who)
        Called by the Radio when a click was made
      • setSelectedItem

        public void setSelectedItem​(java.lang.String text)
        Selects a radio whose text matches the given caption
      • setSelectedItemStartingWith

        public void setSelectedItemStartingWith​(java.lang.String text,
                                                boolean caseInsensitive)
        Selects a radio whose text starts with the given caption
      • setSelectedItem

        protected void setSelectedItem​(Radio who,
                                       boolean checked)
      • getSelectedIndex

        public int getSelectedIndex()
        Returns the currently selected index (in the order that the Radios were added to the container), or -1 if none.
        Since:
        SuperWaba 4.02
      • getSelectedItem

        public Radio getSelectedItem()
        Returns the currently selected Radio, or null if none.
        Since:
        SuperWaba 4.02
      • setSelectedIndex

        public void setSelectedIndex​(int i)
        Selects the given radio and deselects the other one.
        Parameters:
        i - the zero-based index of the radio to be set, or -1 to disable all.
      • setSelectedIndex

        public void setSelectedIndex​(int i,
                                     boolean sendPressEvent)
        Selects the given radio and deselects the other one.
        Parameters:
        i - the zero-based index of the radio to be set, or -1 to disable all.
      • getRadio

        public Radio getRadio​(int idx)
        Returns the Radio at the given index.
        Since:
        TotalCross 1.5
      • getSize

        public int getSize()
        Returns the number of Radio's.