01: package net.xoetrope.samples.controls;
02:
03: import java.awt.Choice;
04: import java.awt.Frame;
05: import java.awt.event.MouseEvent;
06:
07: import net.xoetrope.awt.XButton;
08: import net.xoetrope.xui.XPage;
09: import net.xoetrope.xui.XProjectManager;
10:
11: /**
12: * <p>Title: Xui</p>
13: * <p>Description: </p>
14: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
15: * <p>Company: Xoetrope Ltd.</p>
16: * @author Xoetrope Ltd.
17: * @version 1.0
18: */
19:
20: public class StyleSample extends XPage {
21: XButton closeButton;
22: Frame frame;
23: java.awt.Choice combo;
24:
25: public StyleSample() {
26: XProjectManager.getStyleManager().load("teststyles.xml");
27: frame = new Frame("Style Sample");
28: frame.setLayout(null);
29: frame.setSize(640, 580);
30: String desc = "This example shows how the styles work. The labels with black backgrounds are based on styles defined in";
31: desc += " the teststyles.txt file. The labels are created with a call to the componentFactory and the name of the style";
32: desc += " as a parameter. The edit fields, however, do not have a style associated explicitly but because of the XEdit";
33: desc += " style in the file, they recieve this style. This can also be done with awt components as illustrated by the";
34: desc += " Choice control. This method of associating styles allows the developer or content designer to amend styles";
35: desc += " throughout the application without having to recode the entire application or indeed any of it.";
36:
37: componentFactory.setParentComponent(frame);
38: componentFactory.addComponent(XPage.LABEL, 10, 50, 530, 150,
39: desc);
40: componentFactory.addComponent(XPage.LABEL, 10, 250, 150, 30,
41: "the redonblack style", "redonblack");
42: componentFactory.addComponent(XPage.LABEL, 10, 285, 180, 30,
43: "the redonblack/16 style", "redonblack/16");
44: componentFactory.addComponent(XPage.EDIT, 10, 320, 180, 30,
45: "Some sample text");
46: componentFactory.addComponent(XPage.EDIT, 10, 355, 180, 30,
47: "Some more text");
48: combo = (Choice) componentFactory.addComponent(
49: "java.awt.Choice", 250, 250, 180, 30);
50: combo.add("List item 1");
51: combo.add("List item 2");
52: combo.add("List item 3");
53: combo.add("List item 4");
54:
55: closeButton = (XButton) componentFactory.addComponent(
56: XPage.BUTTON, 10, 540, 130, 25, "Close");
57: this .addMouseHandler(closeButton, "Close");
58: frame.setVisible(true);
59: frame.show();
60: }
61:
62: public static void main(String args[]) {
63: StyleSample styleSample = new StyleSample();
64: }
65:
66: public void Close() {
67: MouseEvent evt = (MouseEvent) this .getCurrentEvent();
68: if (evt.getID() == evt.MOUSE_CLICKED) {
69: frame.setVisible(false);
70: }
71: }
72:
73: }
|