Package totalcross.ui

Class Switch

    • Field Detail

      • ANIMATION_TIME

        public static int ANIMATION_TIME
        The animation time. Set to 0 to disable animations in all Switches.
      • textBackOn

        public java.lang.String textBackOn
        Text to draw when on background or foreground, and when this switch is on or off
      • textForeOn

        public java.lang.String textForeOn
        Text to draw when on background or foreground, and when this switch is on or off
      • textBackOff

        public java.lang.String textBackOff
        Text to draw when on background or foreground, and when this switch is on or off
      • textForeOff

        public java.lang.String textForeOff
        Text to draw when on background or foreground, and when this switch is on or off
      • colorBackOn

        public int colorBackOn
        Text color to draw when on background or foreground, and when this switch is on or off
      • colorForeOn

        public int colorForeOn
        Text color to draw when on background or foreground, and when this switch is on or off
      • colorBackOff

        public int colorBackOff
        Text color to draw when on background or foreground, and when this switch is on or off
      • colorForeOff

        public int colorForeOff
        Text color to draw when on background or foreground, and when this switch is on or off
      • colorBallOn

        public int colorBallOn
        Colors used in material
      • colorBallOff

        public int colorBallOff
        Colors used in material
      • colorBarOn

        public int colorBarOn
        Colors used in material
      • colorBarOff

        public int colorBarOff
        Colors used in material
      • centerText

        public boolean centerText
        Set to true to center text instead of moving it to left or right
    • Constructor Detail

      • Switch

        public Switch()
        Constructs a switch of iOS type. In material UI, there is only one type
      • Switch

        public Switch​(boolean androidType)
        Constructs a switch of the given type. In material UI, there is only one type
    • Method Detail

      • onBoundsChanged

        public void onBoundsChanged​(boolean b)
        Description copied from class: Control
        Called after a setRect.
        Overrides:
        onBoundsChanged in class Control
        Parameters:
        b - If the bounds were changed due to a screen change (rotation, collapse)
      • onColorsChanged

        public void onColorsChanged​(boolean b)
        Description copied from class: Control
        Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. If colorsChanged is true, it was called from setForeColor/setBackColor/Container.add; otherwise, it was called from setEnabled
        Overrides:
        onColorsChanged in class Control
      • setOn

        public void setOn​(boolean b)
        Change the on/off state.
      • isOn

        public boolean isOn()
        Returns true if this switch is ON. Note that, if this Switch has animations, you must call this method only after the animation finishes
      • moveSwitch

        public void moveSwitch​(boolean toLeft)
      • onPaint

        public void onPaint​(Graphics g)
        Description copied from class: Control
        Called to draw the control. When this method is called, the graphics object passed has been translated into the coordinate system of the control and the area behind the control has already been painted.
        Overrides:
        onPaint in class Control
        Parameters:
        g - the graphics object for drawing
        See Also:
        Graphics
      • onEvent

        public void onEvent​(Event event)
        Description copied from class: Control
        Called to process key, pen, control and other posted events.
        Overrides:
        onEvent in class Control
        Parameters:
        event - the event to process
        See Also:
        Event, KeyEvent, PenEvent
      • getPreferredHeight

        public int getPreferredHeight()
        Description copied from class: Control
        Returns the preferred height of this control.
        Overrides:
        getPreferredHeight in class Control
      • getPreferredWidth

        public int getPreferredWidth()
        Description copied from class: Control
        Returns the preferred width of this control.
        Overrides:
        getPreferredWidth in class Control