blob: b2737ed3aa99c2ca97797c96e853a96599be16b0 (
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
|
package com.vaadin.tests.tickets;
import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI.LegacyWindow;
import com.vaadin.ui.VerticalLayout;
public class Ticket2365 extends Application {
@Override
public void init() {
final LegacyWindow mainWin = new LegacyWindow(getClass()
.getSimpleName());
setMainWindow(mainWin);
VerticalLayout lo = new VerticalLayout();
lo.setSizeFull();
mainWin.setContent(lo);
final Panel p = createMultilevelPanel(5, (Panel) null);
Button b = new Button("Toggle parent level size");
lo.addComponent(b);
b.addListener(new Button.ClickListener() {
@Override
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.getContent().setSizeFull();
}
Panel p = new Panel("Panel level " + i--);
p.getContent().setSizeFull();
p.setSizeFull();
panel.addComponent(p);
if (i > 0) {
createMultilevelPanel(i, p);
}
return panel;
}
}
|