Skip to content

v08 002 01 basic elements

Sven Ruppert edited this page Mar 12, 2018 · 2 revisions

V08 - Core Topics - Basic Elements

Label

Button

Layout

Horizontal- / Vertical- Layout

GridLayout

The GridLayout will give you the possibility to place elements in a more or less free way on the screen. For this divide your screen in rows and cols.

Use the following method to create buttons. As first example we will put a button in every defined place inside the Gridlayout.

layout/gridlayout/Grid4x4_001.png

How to do this? First we define a GridLayout with the dimension 4x4.

    final GridLayout grid4X4 = new GridLayout(4, 4);

As next we define a helper method to create a button.

  private Button btn(String caption){
    Button button = new Button(caption);
    button.setSizeFull();
    return button;
  }

Now we will start filling up the Layout. As you can see, the place will be addressed with the coordinates itself. For example ButtonCA will be at place (2,0)

    grid4X4.addComponent(btn("AA"), 0,0);
    grid4X4.addComponent(btn("BA"), 1,0);
    grid4X4.addComponent(btn("CA"), 2,0);
    grid4X4.addComponent(btn("DA"), 3,0);

    grid4X4.addComponent(btn("AB"), 0,1);
    grid4X4.addComponent(btn("BB"), 1,1);
    grid4X4.addComponent(btn("CB"), 2,1);
    grid4X4.addComponent(btn("DB"), 3,1);

Now it is your turn, to create the following versions out of it. Remember, to use more as one place for an element inside the Layout, define the start and stop coordinates.

layout/gridlayout/Grid4x4_002.png

layout/gridlayout/Grid4x4_003.png

layout/gridlayout/Grid4x4_004.png

layout/gridlayout/Grid4x4_005.png

TextField