01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.sample.showcase2.client.layout;
09:
10: import com.gwtext.client.widgets.Panel;
11: import com.gwtext.client.widgets.layout.AnchorLayout;
12: import com.gwtext.client.widgets.layout.AnchorLayoutData;
13: import com.gwtext.client.widgets.layout.FitLayout;
14: import com.gwtext.sample.showcase2.client.ShowcasePanel;
15:
16: public class AnchorSample extends ShowcasePanel {
17:
18: public String getSourceUrl() {
19: return "source/layout/AnchorSample.java.html";
20: }
21:
22: public Panel getViewPanel() {
23: if (panel == null) {
24:
25: panel = new Panel();
26: panel.setLayout(new FitLayout());
27:
28: //add wrapper panel just to dispaly the borders
29: Panel wrapperPanel = new Panel();
30: wrapperPanel.setBorder(true);
31: wrapperPanel
32: .setBodyStyle("border-style:dotted;border-color:blue;");
33:
34: wrapperPanel.setLayout(new AnchorLayout());
35:
36: wrapperPanel
37: .add(
38: new Panel(
39: "Item 1",
40: "Anchor : '100% 20%' width is 100% of the containing element and 20% of its height"),
41: new AnchorLayoutData("100% 20%"));
42: wrapperPanel
43: .add(
44: new Panel(
45: "Item 2",
46: "Anchor : '50% 25%' width is 50% of the containing element and 25% of its height"),
47: new AnchorLayoutData("50% 25%"));
48:
49: wrapperPanel
50: .add(
51: new Panel(
52: "Item 3",
53: "Anchor : '-100 30%' width is (100% of the containing element - 100px) and height is 30% of containing element."),
54: new AnchorLayoutData("-100 30%"));
55:
56: panel.add(wrapperPanel);
57: }
58: return panel;
59: }
60:
61: public String getIntro() {
62: return "This example illustrates the use of AnchorLayout to lay out panels based on anchor values.";
63: }
64: }
|