Class ControlBox


  • public class ControlBox
    extends Window
    A popup window that displays any Control, given as parameter to the constructor.
    • Field Detail

      • msg

        protected Label msg
      • prefW

        protected int prefW
      • prefH

        protected int prefH
      • yPosition

        public int yPosition
        Defines the y position on screen where this window opens. Can be changed to TOP or BOTTOM. Defaults to CENTER.
        See Also:
        Control.CENTER, Control.TOP, Control.BOTTOM
      • buttonKeys

        public int[] buttonKeys
        If you set the buttonCaptions array in the construction, you can also set this public field to an int array of the keys that maps to each of the buttons. For example, if you set the buttons to {"Ok","Cancel"}, you can map the enter key for the Ok button and the escape key for the Cancel button by assigning:
         buttonKeys = new int[]{SpecialKeys.ENTER,SpecialKeys.ESCAPE};
         
        Note that if you use the default Ok/Cancel buttons, this mapping is already done.
        Since:
        TotalCross 1.27
    • Constructor Detail

      • ControlBox

        public ControlBox​(java.lang.String title,
                          java.lang.String text,
                          Control cb)
        Constructs a ControlBox with the given parameters, and an Ok and a Cancel buttons. The control may have at least one item, which will be used to determine the preferred size.
        Parameters:
        title - The window's title.
        text - The text that will be displayed in a Label above the control.
        cb - The control that will be used to get input from the user.
      • ControlBox

        public ControlBox​(java.lang.String title,
                          java.lang.String text,
                          Control cb,
                          java.lang.String[] buttonCaptions)
        Constructs a ControlBox with the given parameters. The control may have at least one item, which will be used to determine the preferred size.
        Parameters:
        title - The window's title.
        text - The text that will be displayed in a Label above the control.
        cb - The control that will be used to get input from the user.
        buttonCaptions - The button captions that will be used in the PushButtonGroup.
      • ControlBox

        public ControlBox​(java.lang.String title,
                          java.lang.String text,
                          Control cb,
                          int prefW,
                          int prefH,
                          java.lang.String[] buttonCaptions)
        Constructs a ControlBox with the given parameters. The control may have at least one item, which will be used to determine the preferred size.
        Parameters:
        title - The window's title.
        text - The text that will be displayed in a Label above the control.
        cb - The control that will be used to get input from the user.
        buttonCaptions - The button captions that will be used in the PushButtonGroup, or null to hide them.
        prefW - The preferred width for the control. You can also use FILL or PREFERREED
        prefH - The preferred height for the control.
      • ControlBox

        public ControlBox​(java.lang.String title,
                          java.lang.String text,
                          Control cb,
                          int prefW,
                          int prefH,
                          java.lang.String[] buttonCaptions,
                          int buttonRows)
        Constructs a ControlBox with the given parameters. The control may have at least one item, which will be used to determine the preferred size.
        Parameters:
        title - The window's title.
        text - The text that will be displayed in a Label above the control.
        cb - The control that will be used to get input from the user.
        buttonCaptions - The button captions that will be used in the PushButtonGroup, or null to hide them.
        prefW - The preferred width for the control. You can also use FILL or PREFERREED
        prefH - The preferred height for the control.
        buttonRows - The number of rows for the buttons.
    • Method Detail

      • onPopup

        protected void onPopup()
        Description copied from class: Window
        Placeholder called imediatly before the popup began. The default implementation does nothing.
        Overrides:
        onPopup in class Window
      • getPressedButtonIndex

        public int getPressedButtonIndex()
        Returns the pressed button index, starting from 0
      • getControl

        public Control getControl()
        returns the control associated
      • postUnpop

        protected void postUnpop()
        Description copied from class: Window
        Placeholder called after the unpop is done and after the repaint of the other window. The default implementation does nothing.
        Overrides:
        postUnpop in class Window