summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/tickets/Ticket2432.java
blob: f21e6a6752ab9ac5c782cbd3ebaf2b05784dc6de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.vaadin.tests.tickets;

import com.vaadin.Application;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Layout.AlignmentHandler;
import com.vaadin.ui.Layout.SpacingHandler;
import com.vaadin.ui.UI.LegacyWindow;

public class Ticket2432 extends Application.LegacyApplication {

    @Override
    public void init() {

        LegacyWindow w = new LegacyWindow();
        setMainWindow(w);
        w.getContent().setSizeFull();
        ((SpacingHandler) w.getContent()).setSpacing(true);

        Layout layout = new GridLayout(3, 3);
        populateLayout(layout);
        w.addComponent(layout);
        layout = new HorizontalLayout();
        populateLayout(layout);
        w.addComponent(layout);

    }

    private static Alignment[] alignments = new Alignment[] {
            Alignment.TOP_LEFT, Alignment.TOP_CENTER, Alignment.TOP_RIGHT,
            Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER,
            Alignment.MIDDLE_RIGHT, Alignment.BOTTOM_LEFT,
            Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT };

    private void populateLayout(Layout layout) {
        layout.setSizeFull();
        for (int i = 0; i < 9; i++) {
            Label l = new Label("M");
            Alignment a = alignments[i];
            l.setCaption(a.getHorizontalAlignment() + " "
                    + a.getVerticalAlignment() + " " + a.getBitMask());
            layout.addComponent(l);
            ((AlignmentHandler) layout).setComponentAlignment(l, a);
        }

    }

}