01: package net.xoetrope.samples.counterexample.ide;
02:
03: import net.xoetrope.awt.XButton;
04: import net.xoetrope.awt.XEdit;
05: import net.xoetrope.awt.XLabel;
06: import net.xoetrope.xui.XPage;
07: import net.xoetrope.awt.XPanel;
08: import net.xoetrope.xui.style.XStyleFactory;
09: import net.xoetrope.xui.helper.BuddyHelper;
10:
11: public class XuiBoilerPlate extends XPage {
12: XButton okBtn, cancelBtn, calculateBtn;
13: XEdit widthEdit, heightEdit;
14: XLabel areaText;
15:
16: public XuiBoilerPlate() {
17: BuddyHelper buddy = new BuddyHelper(
18: (XStyleFactory) componentFactory);
19: componentFactory.setParentComponent(this );
20: componentFactory.addComponent(XPage.LABEL, 12, 22, 213, 23,
21: "Area Calculator");
22:
23: XPanel leftPanel = (XPanel) componentFactory.addComponent(
24: XPage.PANEL, 12, 68, 228, 303, null, null);
25: leftPanel.setDrawFrame(1);
26: componentFactory.setParentComponent(leftPanel);
27: XLabel intro = (XLabel) componentFactory
28: .addComponent(
29: XPage.LABEL,
30: 10,
31: 10,
32: 180,
33: 240,
34: "Once upon a time there was a simple programmer who wished to calculate "
35: + "the area of a room, but being a very slow mathematician he decide "
36: + "to create a calculator. Here is what he did.",
37: null);
38:
39: XPanel rightPanel = (XPanel) componentFactory.addComponent(
40: XPage.PANEL, 12, 68, 228, 303, null, null);
41: rightPanel.setDrawFrame(1);
42: componentFactory.setParentComponent(rightPanel);
43: widthEdit = (XEdit) buddy.addComponent(XPage.EDIT, 336, 11, 49,
44: 25, "OK", "Width", null);
45: heightEdit = (XEdit) buddy.addComponent(XPage.EDIT, 392, 11,
46: 67, 25, "Cancel", "Height", null);
47: calculateBtn = (XButton) componentFactory.addComponent(
48: XPage.BUTTON, 392, 11, 67, 25, "Calculate", null);
49: areaText = (XLabel) buddy.addComponent(XPage.LABEL, 392, 11,
50: 67, 25, "Cancel", "Height", null);
51: componentFactory.addComponent(XPage.IMAGE, 392, 11, 67, 25,
52: "RoomImage.jpg", null);
53:
54: XPanel bottomPanel = (XPanel) componentFactory.addComponent(
55: XPage.PANEL, 12, 68, 228, 303, null, null);
56: bottomPanel.setDrawFrame(1);
57: componentFactory.setParentComponent(bottomPanel);
58: okBtn = (XButton) componentFactory.addComponent(XPage.BUTTON,
59: 336, 11, 49, 25, "OK", null);
60: cancelBtn = (XButton) componentFactory.addComponent(
61: XPage.BUTTON, 392, 11, 67, 25, "Cancel", null);
62:
63: addMouseHandler(calculateBtn, "calculate");
64: addMouseHandler(okBtn, "okClicked");
65: addMouseHandler(cancelBtn, "cancelClicked");
66: }
67:
68: void calculate() {
69: int width = Integer.parseInt(widthEdit.getText());
70: int height = Integer.parseInt(heightEdit.getText());
71:
72: areaText.setText(Integer.toString(width * height));
73: }
74:
75: void cancelClicked() {
76: widthEdit.setText("10");
77: heightEdit.setText("10");
78: }
79:
80: void okClicked() {
81: System.exit(0);
82: }
83: }
|