01: package net.xoetrope.xui.test;
02:
03: import java.awt.Button;
04: import java.awt.Component;
05: import java.awt.Frame;
06:
07: import junit.framework.TestCase;
08: import net.xoetrope.awt.XLabel;
09: import net.xoetrope.xui.XPage;
10: import net.xoetrope.xui.style.XStyleFactory;
11:
12: /**
13: * Title: Xui
14: * Description:
15: * Copyright: Copyright (c) Xoetrope Ltd., 1998-2003
16: * Company: Xoetrope Ltd.
17: * @author Xoetrope Ltd.
18: * @version 1.0
19: */
20:
21: public class TestXPanel extends TestCase {
22: public TestXPanel() {
23: }
24:
25: public static void main(String args[]) {
26: TestXPanel testpanel = new TestXPanel();
27: testpanel.addComponents();
28: }
29:
30: public void testCtor() {
31: Frame testFrame = new Frame("Xui Test");
32: Component pnl = addComponents();
33:
34: testFrame.add(pnl);
35: testFrame.setSize(800, 600);
36: testFrame.show();
37:
38: try {
39: Thread.currentThread().sleep(400);
40: } catch (Exception e) {
41: }
42: ;
43: testFrame.hide();
44: }
45:
46: private Component addComponents() {
47: // XStyleManager style = TestStyles.getStyles();
48: XStyleFactory compfactory = null;
49: try {
50: compfactory = new XStyleFactory("net.xoetrope.xui");
51: } catch (Exception ex) {
52: ex.printStackTrace();
53: }
54: Component xpanel = compfactory.addComponent(XPage.PANEL, 0, 0,
55: 800, 600, null, "base/grey");
56: Component xpanelc1 = compfactory.addComponent(XPage.PANEL, 10,
57: 10, 160, 100, null, null);
58: Component xpanelc2 = compfactory.addComponent(XPage.PANEL, 10,
59: 160, 360, 160, null, null);
60:
61: /* First child panel */
62: compfactory.setParentComponent(xpanelc1);
63: XLabel lbl1 = (XLabel) compfactory.addComponent(XPage.LABEL,
64: 10, 2, 80, 25, "test 1", null);
65: XLabel lbl2 = (XLabel) compfactory.addComponent(XPage.LABEL,
66: 10, 30, 80, 25, "test 2", null);
67:
68: /* Second child panel */
69: compfactory.setParentComponent(xpanelc2);
70: XLabel lbl3 = (XLabel) compfactory.addComponent(XPage.LABEL,
71: 10, 2, 120, 50, "this is a piece of wrapping text",
72: "bold");
73: XLabel lbl4 = (XLabel) compfactory.addComponent(XPage.LABEL,
74: 10, 90, 120, 20, "test 4", "bold");
75:
76: /* Add a generic component */
77: Button b = (Button) compfactory.addComponent(XPage.BUTTON, 120,
78: 70, 150, 35, null);
79: b.setActionCommand("calculate");
80: b.setLabel("Test button");
81: b = (Button) compfactory.addComponent(XPage.BUTTON, 120, 110,
82: 150, 35, null);
83: b.setLabel("Click me!!!");
84:
85: return xpanel;
86: }
87: }
|