blob: c37d5a8495ef7d23446c46c9671f62c47e2b6807 (
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
|
package com.itmill.toolkit.tests.tickets;
import com.itmill.toolkit.Application;
import com.itmill.toolkit.ui.Button;
import com.itmill.toolkit.ui.Panel;
import com.itmill.toolkit.ui.VerticalLayout;
import com.itmill.toolkit.ui.Window;
import com.itmill.toolkit.ui.Button.ClickEvent;
public class Ticket2365 extends Application {
public void init() {
final Window mainWin = new Window(getClass().getSimpleName());
setMainWindow(mainWin);
VerticalLayout lo = new VerticalLayout();
lo.setSizeFull();
mainWin.setLayout(lo);
final Panel p = createMultilevelPanel(5, (Panel) null);
Button b = new Button("Toggle parent level size");
lo.addComponent(b);
b.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
if (p.getWidth() > 0) {
p.setSizeUndefined();
} else {
p.setSizeFull();
}
}
});
lo.addComponent(p);
lo.setExpandRatio(p, 1);
}
private Panel createMultilevelPanel(int i, Panel panel) {
if (panel == null) {
panel = new Panel("Panel level " + i);
panel.setSizeFull();
panel.getLayout().setSizeFull();
}
Panel p = new Panel("Panel level " + i--);
p.getLayout().setSizeFull();
p.setSizeFull();
panel.addComponent(p);
if (i > 0) {
createMultilevelPanel(i, p);
}
return panel;
}
}
|