blob: dcc821b8064fec5453ad9da40b943a4362adec29 (
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
|
/*
* Copyright 2000-2013 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
public class TestForAlignments extends CustomComponent {
public TestForAlignments() {
final VerticalLayout main = new VerticalLayout();
final Button b1 = new Button("Right");
final Button b2 = new Button("Left");
final Button b3 = new Button("Bottom");
final Button b4 = new Button("Top");
final TextField t1 = new TextField("Right aligned");
final TextField t2 = new TextField("Bottom aligned");
final DateField d1 = new DateField("Center aligned");
final DateField d2 = new DateField("Center aligned");
final VerticalLayout vert = new VerticalLayout();
vert.addComponent(b1);
vert.addComponent(b2);
vert.addComponent(t1);
vert.addComponent(d1);
// vert.getSize().setWidth(500);
vert.setComponentAlignment(b1, Alignment.TOP_RIGHT);
vert.setComponentAlignment(b2, Alignment.TOP_LEFT);
vert.setComponentAlignment(t1, Alignment.TOP_RIGHT);
vert.setComponentAlignment(d1, Alignment.TOP_CENTER);
final HorizontalLayout hori = new HorizontalLayout();
hori.addComponent(b3);
hori.addComponent(b4);
hori.addComponent(t2);
hori.addComponent(d2);
// hori.getSize().setHeight(200);
hori.setComponentAlignment(b3, Alignment.BOTTOM_LEFT);
hori.setComponentAlignment(b4, Alignment.TOP_LEFT);
hori.setComponentAlignment(t2, Alignment.BOTTOM_LEFT);
hori.setComponentAlignment(d2, Alignment.MIDDLE_LEFT);
main.addComponent(vert);
main.addComponent(hori);
setCompositionRoot(main);
}
}
|