blob: 55e95f0eb3b291d19e533124c23231d17f46f2f1 (
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
|
package com.vaadin.tests.tickets;
import java.util.ArrayList;
import java.util.List;
import com.vaadin.LegacyApplication;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI.LegacyWindow;
public class Ticket1982 extends LegacyApplication {
private List<TitleBar> components = new ArrayList<TitleBar>();
@Override
public void init() {
LegacyWindow main = new LegacyWindow();
setMainWindow(main);
GridLayout gl = new GridLayout(2, 2);
gl.setSizeFull();
main.setContent(gl);
gl.setMargin(true);
TitleBar t1 = new TitleBar("Title 1", gl);
TitleBar t2 = new TitleBar("Title 2", gl);
TitleBar t3 = new TitleBar("Title 3", gl);
TitleBar t4 = new TitleBar("Title 4", gl);
components.add(t1);
components.add(t2);
components.add(t3);
components.add(t4);
restoreComponents(gl);
}
private void restoreComponents(GridLayout gl) {
gl.removeAllComponents();
gl.addComponent(components.get(0));
gl.addComponent(components.get(1));
gl.addComponent(components.get(2));
gl.addComponent(components.get(3));
}
private class TitleBar extends HorizontalLayout {
private Button max = new Button("Max");
private Button min = new Button("Min");
private GridLayout layout;
public TitleBar(String title, GridLayout layout) {
super();
this.layout = layout;
addComponent(new Label(title));
addComponent(max);
addComponent(min);
min.setVisible(false);
max.addListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
min.setVisible(true);
max.setVisible(false);
TitleBar.this.layout.removeAllComponents();
TitleBar.this.layout
.addComponent(TitleBar.this, 0, 0, 1, 1);
}
});
min.addListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
min.setVisible(false);
max.setVisible(true);
restoreComponents(TitleBar.this.layout);
}
});
}
}
}
|