Package totalcross.ui

Class Spacer


  • public class Spacer
    extends Control
    Control used to add a space between controls. It shows nothing on screen. Here's a sample of how to use it:
     Spacer s;
     add(s = new Spacer("  "),CENTER,AFTER+2);
     add(btnClear = new Button("Clear"), AFTER,SAME, s);
     add(btnOK = new Button("OK"), BEFORE, SAME, SAME, SAME, s);
     
    This sample will place two buttons centered on screen, like this:
     ==========  ===========
     |   Ok   |  |  Clear  |
     ==========  ===========
     
    Since:
    TotalCross 1.22
    • Constructor Detail

      • Spacer

        public Spacer()
        Constructs a new Spacer with width and height = 0.
      • Spacer

        public Spacer​(int x,
                      int y)
        Constructs a new Spacer using the given x and y values.
      • Spacer

        public Spacer​(java.lang.String s)
        Constructs a new Spacer using the given String, whose width will be the horizontal spacement. The vertical spacement will be the font's height.
    • Method Detail

      • getPreferredWidth

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

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