01: package net.xoetrope.samples.advanced;
02:
03: import net.xoetrope.awt.XButton;
04: import net.xoetrope.awt.XEdit;
05: import net.xoetrope.xui.XPage;
06: import net.xoetrope.xui.style.XStyleFactory;
07: import net.xoetrope.xui.helper.BuddyHelper;
08:
09: /**
10: * <p>Title: Xui</p>
11: * <p>Description: </p>
12: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
13: * <p>Company: Xoetrope Ltd.</p>
14: * @author not attributable
15: * @version 1.0
16: */
17:
18: public class BuddyHelperSample extends XPage {
19: BuddyHelper buddy;
20: XEdit txtFirstname, txtSurname, txtAge;
21: XButton btnDisable, btnSetVisible;
22:
23: public BuddyHelperSample() {
24: buddy = new BuddyHelper((XStyleFactory) componentFactory);
25:
26: txtFirstname = (XEdit) buddy.addComponent(XPage.EDIT, 20, 50,
27: 130, 25, "Firstname", "", null);
28: txtSurname = (XEdit) buddy.addComponent(XPage.EDIT, 20, 80,
29: 130, 25, "Surname", "", null);
30: txtAge = (XEdit) buddy.addComponent(XPage.EDIT, 20, 95, 130,
31: 110, 355, 25, "Age", "", "Years", null);
32: btnDisable = (XButton) componentFactory.addComponent(
33: XPage.BUTTON, 30, 200, 80, 20, "Set Enabled");
34: btnSetVisible = (XButton) componentFactory.addComponent(
35: XPage.BUTTON, 130, 200, 80, 20, "Set Visible");
36: addMouseHandler(btnDisable, "toggleDisabled");
37: addMouseHandler(btnSetVisible, "toggleVisible");
38: }
39:
40: public void toggleDisabled() {
41: if (wasMouseClicked())
42: buddy.setEnabled(txtFirstname, !txtFirstname.isEnabled());
43: }
44:
45: public void toggleVisible() {
46: if (wasMouseClicked())
47: buddy.setVisible(txtAge, !txtAge.isVisible());
48: }
49: }
|