01: package net.xoetrope.builder.editor.dialog;
02:
03: import java.awt.Point;
04: import java.awt.event.ActionEvent;
05: import java.awt.event.ActionListener;
06: import javax.swing.JButton;
07: import javax.swing.JDialog;
08: import javax.swing.border.EtchedBorder;
09:
10: import net.xoetrope.builder.editor.XEditorProject;
11: import net.xoetrope.builder.editor.XPageList;
12: import net.xoetrope.builder.editor.XuiDefaults;
13: import net.xoetrope.swing.XButton;
14: import net.xoetrope.xui.XComponentFactory;
15: import net.xoetrope.xui.XPage;
16:
17: /**
18: * <p>A dialog for selection of the XUI page</p>
19: * <p>Copyright (c) Xoetrope Ltd., 1998-2003</p>
20: * $Revision: 1.5 $
21: */
22: public class XPageSelectionDialog extends JDialog implements
23: ActionListener {
24: protected JButton btnOK;
25: protected String selectedPage;
26: protected XPageList pageList;
27:
28: public XPageSelectionDialog(XEditorProject project) {
29: setTitle("Choose the page");
30: getContentPane().setLayout(null);
31: setModal(true);
32:
33: setFont(XuiDefaults.defaultFont);
34:
35: XComponentFactory factory = new XComponentFactory(
36: XPage.XUI_SWING_PACKAGE);
37: factory.setParentComponent(getContentPane());
38:
39: pageList = new XPageList();
40: pageList.setBounds(10, 8, 210, 150);
41: pageList.setFont(XuiDefaults.defaultFont);
42: getContentPane().add(pageList);
43: pageList.projectLoaded(project);
44: pageList.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
45:
46: XButton okButton = (XButton) factory.addComponent(XPage.BUTTON,
47: 120, 170, 100, 20, "OK");
48: okButton.setFont(XuiDefaults.defaultFont);
49: okButton.addActionListener(this );
50:
51: XButton cancelButton = (XButton) factory.addComponent(
52: XPage.BUTTON, 10, 170, 100, 20, "Cancel");
53: cancelButton.setFont(XuiDefaults.defaultFont);
54: cancelButton.addActionListener(this );
55:
56: setSize(238, 232);
57: setModal(true);
58: }
59:
60: public void actionPerformed(ActionEvent evt) {
61: if (evt.getActionCommand().compareTo("OK") == 0)
62: selectedPage = pageList.getSelectedPage();
63:
64: hide();
65: }
66:
67: public void show(Point pt) {
68: setLocation(pt);
69: super .show();
70: }
71:
72: public String getSelectedPage() {
73: return selectedPage;
74: }
75: }
|