01: //WebOnSwing - Web Application Framework
02: //Copyright (C) 2003 Fernando Damian Petrola
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //This library is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: //Lesser General Public License for more details.
13: //
14: //You should have received a copy of the GNU Lesser General Public
15: //License along with this library; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17:
18: package examples;
19:
20: import java.awt.*;
21: import java.awt.event.*;
22:
23: import javax.swing.*;
24:
25: import net.ar.webonswing.*;
26:
27: public class ModalDemo extends JDialog implements ActionListener {
28: protected JTextField theTextField;
29:
30: public ModalDemo() {
31: init("0");
32: }
33:
34: public ModalDemo(String aCounter) {
35: init(aCounter);
36: }
37:
38: private void init(String aCounter) {
39: JPanel theContentPane = (JPanel) getContentPane();
40:
41: JButton theOpenButton = new JButton("open new modal");
42: theOpenButton.addActionListener(this );
43:
44: JButton theCloseButton = new JButton("close");
45: theCloseButton.addActionListener(new ActionListener() {
46: public void actionPerformed(ActionEvent e) {
47: WosFramework.hide(ModalDemo.this );
48: }
49: });
50:
51: theTextField = new JTextField(String.valueOf(aCounter));
52: theTextField.putClientProperty("theContributor",
53: ModalDemoTextFieldContributor.class.getName());
54:
55: theContentPane.setLayout(new GridLayout(3, 1));
56: theContentPane.add(theOpenButton);
57: theContentPane.add(theCloseButton);
58: theContentPane.add(theTextField);
59: }
60:
61: public void processResults(ModalDemo aWindow) {
62: theTextField.setText(aWindow.getTextField().getText()
63: + Integer.toHexString((Integer.parseInt(aWindow
64: .getTextField().getText().substring(
65: aWindow.getTextField().getText()
66: .length() - 1), 16) - 1)));
67: }
68:
69: public void actionPerformed(ActionEvent e) {
70: ModalDemo theNewWindow = new ModalDemo(getTextField().getText()
71: + Integer.toHexString((Integer.parseInt(getTextField()
72: .getText().substring(
73: getTextField().getText().length() - 1),
74: 16) + 1)));
75: theNewWindow.setModal(true);
76: WosFramework.showAndExecute(ModalDemo.this , theNewWindow,
77: "processResults");
78: }
79:
80: public JTextField getTextField() {
81: return theTextField;
82: }
83:
84: public void setTextField(JTextField aField) {
85: theTextField = aField;
86: }
87:
88: }
|