01: package net.xoetrope.samples.apps;
02:
03: import net.xoetrope.awt.XButton;
04: import net.xoetrope.awt.XComboBox;
05: import net.xoetrope.awt.XEdit;
06: import net.xoetrope.awt.XLabel;
07: import net.xoetrope.xui.XPage;
08: import net.xoetrope.xui.XPageManager;
09: import net.xoetrope.xui.style.XStyleFactory;
10: import net.xoetrope.xui.data.XTextBinding;
11: import net.xoetrope.xui.helper.BuddyHelper;
12: import net.xoetrope.xui.XProjectManager;
13:
14: /**
15: * <p>Title: Xui</p>
16: * <p>Description: </p>
17: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
18: * <p>Company: Xoetrope Ltd.</p>
19: * @author not attributable
20: * @version 1.0
21: */
22:
23: public class SecondPage extends XPage {
24: XEdit txtPrice, txtDeposit;
25: XLabel lblAdvance;
26: XComboBox cmbOccupations;
27: XButton btnBack, btnNext;
28:
29: public SecondPage() {
30: BuddyHelper buddy = new BuddyHelper(
31: (XStyleFactory) componentFactory);
32:
33: componentFactory.addComponent(XPage.LABEL, 10, 10, 200, 25,
34: "Please enter finance details", "base/PageTitle");
35: txtPrice = (XEdit) buddy.addComponent(XPage.EDIT, 20, 50, 130,
36: 25, "Car price(€)", "", null);
37: txtDeposit = (XEdit) buddy.addComponent(XPage.EDIT, 20, 80,
38: 130, 25, "Deposit(€)", "", null);
39: lblAdvance = (XLabel) buddy.addComponent(XPage.LABEL, 20, 110,
40: 130, 25, "Advance(€)", "", "base/alert");
41: btnBack = (XButton) componentFactory.addComponent(XPage.BUTTON,
42: 20, 220, 60, 25, "Back");
43: btnNext = (XButton) componentFactory.addComponent(XPage.BUTTON,
44: 120, 220, 60, 25, "Next");
45: populateComponents();
46: mapEvent();
47: }
48:
49: public void mapEvent() {
50: addMouseHandler(btnBack, "previousScreen");
51: addMouseHandler(btnNext, "nextScreen");
52: addTextHandler(txtPrice, "changeAdvance");
53: addTextHandler(txtDeposit, "changeAdvance");
54: }
55:
56: public void populateComponents() {
57: addBinding(new XTextBinding(txtPrice, "finance/price"));
58: addBinding(new XTextBinding(txtDeposit, "finance/deposit"));
59: addBinding(new XTextBinding(lblAdvance, "finance/advance"));
60: }
61:
62: public void changeAdvance() {
63: float price = 0;
64: float deposit = 0;
65: if (txtPrice.getText().length() > 0
66: && txtDeposit.getText().length() > 0) {
67: try {
68: price = new Float(txtPrice.getText()).floatValue();
69: deposit = new Float(txtDeposit.getText()).floatValue();
70: lblAdvance.setText(String.valueOf(price - deposit));
71: } catch (Exception ex) {
72: ex.printStackTrace();
73: }
74: } else {
75: lblAdvance.setText("0.0");
76: }
77: }
78:
79: public void previousScreen() {
80: if (wasMouseClicked()) {
81: XProjectManager.getPageManager().showPage("FirstPage");
82: }
83: }
84:
85: public void nextScreen() {
86: if (wasMouseClicked()) {
87: XProjectManager.getPageManager().showPage("LastPage");
88: }
89: }
90: }
|