blob: 9440855bbe990df540e145b2a80a2747cfbab308 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
package com.vaadin.tests.tickets;
import com.vaadin.Application;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Layout.AlignmentHandler;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI.LegacyWindow;
import com.vaadin.ui.VerticalLayout;
public class Ticket1966 extends Application.LegacyApplication {
@Override
public void init() {
LegacyWindow w = new LegacyWindow(getClass().getName());
setMainWindow(w);
// setTheme("tests-tickets");
w.setContent(new GridLayout(2, 2));
// w.getLayout().setSizeFull();
createUI((Layout) w.getContent());
}
private void createUI(Layout layout) {
orderedLayout(layout);
gridLayout(layout);
}
private void gridLayout(Layout layout) {
Panel p = new Panel("GridLayout");
layout.addComponent(p);
GridLayout gl = new GridLayout(1, 4);
gl.setCaption("Horizontal");
Button b;
b = new Button("Wide button");
b.setWidth("500px");
gl.addComponent(b);
addButtons(gl);
p.addComponent(gl);
/* VERTICAL */
gl = new GridLayout(4, 1);
gl.setCaption("Vertical");
addButtons(gl);
b = new Button("High button");
b.setHeight("200px");
gl.addComponent(b);
p.addComponent(gl);
}
private void orderedLayout(Layout layout) {
Panel p = new Panel("OrderedLayout");
layout.addComponent(p);
AbstractOrderedLayout ol = new VerticalLayout();
ol.setCaption("Horizontal");
// ol.setWidth("100%");
Button b;
b = new Button("Wide button");
b.setWidth("500px");
ol.addComponent(b);
addButtons(ol);
p.addComponent(ol);
/* VERTICAL */
ol = new HorizontalLayout();
ol.setCaption("Vertical");
addButtons(ol);
b = new Button("High button");
b.setHeight("200px");
ol.addComponent(b);
p.addComponent(ol);
}
private void addButtons(Layout ol) {
ol.addComponent(getButton(ol, Alignment.TOP_LEFT));
ol.addComponent(getButton(ol, Alignment.MIDDLE_CENTER));
ol.addComponent(getButton(ol, Alignment.BOTTOM_RIGHT));
}
private Button getButton(Layout l, Alignment align) {
Button b = new Button("Narrow Button - "
+ align.getHorizontalAlignment() + " - "
+ align.getVerticalAlignment());
b.setWidth("100px");
((AlignmentHandler) l).setComponentAlignment(b, align);
return b;
}
}
|