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
|
package com.vaadin.tests.layouts;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
public class GridLayoutMoveComponent extends TestBase {
@Override
protected void setup() {
final GridLayout grid = new GridLayout(2, 3);
grid.setCaption("Fixed size grid");
grid.setWidth("300px");
grid.setHeight("100px");
addComponent(grid);
final Label l = new Label("100% label");
final Button b = new Button("100px button");
b.setWidth("100px");
final TextField tf = new TextField("Undef textfield");
// Adding component to grid
grid.addComponent(l, 0, 0);
grid.addComponent(b, 0, 1);
grid.addComponent(tf, 0, 2);
addComponent(new Button("Shift label right",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
// Moving component from 0,0 -> 1,0
grid.removeComponent(l);
grid.addComponent(l, 1, 0);
}
}));
addComponent(new Button("Shift button right",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
grid.removeComponent(b);
grid.addComponent(b, 1, 1);
}
}));
addComponent(new Button("Shift text field right",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
grid.removeComponent(tf);
grid.addComponent(tf, 1, 2);
}
}));
}
@Override
protected String getDescription() {
return "Click the buttons below the GridLayout to move the components to the right. Should definitely work no matter what.";
}
@Override
protected Integer getTicketNumber() {
return 5525;
}
}
|