KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwtx > swing > JDialog


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9
10    $Log: JDialog.java,v $
11    Revision 1.26 2004/04/19 15:43:25 bobintetley
12    Missing (and incorrect) Dialog/JDialog constructors implemented
13
14    Revision 1.25 2004/04/16 10:19:06 dannaab
15    Misc bug fixes, InputMap implementation, preliminary undo support
16
17    Revision 1.24 2004/03/22 15:10:22 bobintetley
18    JRootPane and JLayeredPane implementation
19
20    Revision 1.23 2004/03/18 15:13:22 bobintetley
21    Temporary fix to getRootPane()
22
23    Revision 1.22 2004/03/18 14:42:11 bobintetley
24    Fix to Window hierarchy to match Swing, and fix to allow MDI apps
25       to work under SWT 2.x
26
27    Revision 1.21 2004/02/02 14:40:22 bobintetley
28    Non-modal dialogs now work correctly
29
30    Revision 1.20 2004/01/20 15:00:57 bobintetley
31    Fixed dialog modality
32
33    Revision 1.19 2004/01/16 09:35:47 bobintetley
34    Full event dispatch thread support!
35
36    Revision 1.18 2003/12/17 13:20:58 bobintetley
37    Full showInputDialog support and JDialogs can now block correctly
38
39    Revision 1.17 2003/12/15 18:29:57 bobintetley
40    Changed setParent() method to setSwingWTParent() to avoid conflicts with applications
41
42    Revision 1.16 2003/12/15 17:39:11 bobintetley
43    Missing implementations completed
44
45    Revision 1.15 2003/12/15 15:54:25 bobintetley
46    Additional core methods
47
48    Revision 1.14 2003/12/14 09:13:38 bobintetley
49    Added CVS log to source headers
50
51 */

52
53
54 package swingwtx.swing;
55
56 import swingwt.awt.Component;
57 import swingwt.awt.Container;
58 import swingwt.awt.Frame;
59 import swingwt.awt.GraphicsConfiguration;
60
61 public class JDialog extends swingwt.awt.Dialog implements WindowConstants, RootPaneContainer {
62     
63     protected int closeOperation = WindowConstants.DISPOSE_ON_CLOSE;
64     
65     public JDialog() {super(); }
66     public JDialog(swingwt.awt.Dialog owner) { super(owner); }
67     public JDialog(swingwt.awt.Dialog owner, boolean modal) { super(owner, modal); }
68     public JDialog(swingwt.awt.Dialog owner, String JavaDoc title) { super(owner, title); }
69     public JDialog(swingwt.awt.Dialog owner, String JavaDoc title, boolean modal) { super(owner, title, modal); }
70     public JDialog(swingwt.awt.Dialog owner, String JavaDoc title, boolean modal, GraphicsConfiguration gc) { super(owner, title, modal, gc); }
71     public JDialog(Frame owner) { super(owner); }
72     public JDialog(Frame owner, boolean modal) { super(owner, modal); }
73     public JDialog(Frame owner, String JavaDoc title) { super(owner, title); }
74     public JDialog(Frame owner, String JavaDoc title, boolean modal) { super(owner, title, modal); }
75     public JDialog(Frame owner, String JavaDoc title, boolean modal, GraphicsConfiguration gc) { super(owner, title, modal, gc); }
76
77     public int getDefaultCloseOperation() {
78         return closeOperation;
79     }
80     
81     public void setDefaultCloseOperation(int operation) {
82         closeOperation = operation;
83     }
84     
85     public Container getContentPane() {
86         return rootPane.getContentPane();
87     }
88     
89     public Component getGlassPane() {
90         return rootPane.getGlassPane();
91     }
92     
93     public JLayeredPane getLayeredPane() {
94         return rootPane.getLayeredPane();
95     }
96     
97     public JRootPane getRootPane() {
98         return rootPane;
99     }
100     
101     public void setContentPane(Container contentPane) {
102         rootPane.setContentPane(contentPane);
103     }
104     
105     public void setGlassPane(Component glassPane) {
106         rootPane.setGlassPane(glassPane);
107     }
108     
109     public void setLayeredPane(JLayeredPane layeredPane) {
110         rootPane.setLayeredPane(layeredPane);
111     }
112     
113     public void registerWindowEvents() {
114         
115         // Overriden here so we can manage default close operations.
116

117         peer.addShellListener(new org.eclipse.swt.events.ShellListener() {
118             public void shellActivated(org.eclipse.swt.events.ShellEvent e) {
119                 processWindowEvent(swingwt.awt.event.WindowEvent.WINDOW_ACTIVATED);
120             }
121             public void shellClosed(org.eclipse.swt.events.ShellEvent e) {
122                 isClosed = true;
123                 processWindowEvent(swingwt.awt.event.WindowEvent.WINDOW_CLOSING);
124                 processWindowEvent(swingwt.awt.event.WindowEvent.WINDOW_CLOSED);
125                 // See what's set for the default close operation and handle it
126
switch (closeOperation) {
127                     case WindowConstants.DISPOSE_ON_CLOSE: e.doit = true; SwingWTUtils.decrementWindowReferences(); break;
128                     case WindowConstants.DO_NOTHING_ON_CLOSE: e.doit = false; break;
129                     case WindowConstants.EXIT_ON_CLOSE: e.doit = true; SwingWTUtils.decrementWindowReferences(); System.exit(0); break;
130                     case WindowConstants.HIDE_ON_CLOSE: e.doit = false; peer.setVisible(false); break;
131                 }
132             }
133             public void shellDeactivated(org.eclipse.swt.events.ShellEvent e) {
134                 processWindowEvent(swingwt.awt.event.WindowEvent.WINDOW_DEACTIVATED);
135             }
136             public void shellDeiconified(org.eclipse.swt.events.ShellEvent e) {
137                 processWindowEvent(swingwt.awt.event.WindowEvent.WINDOW_DEICONIFIED);
138             }
139             public void shellIconified(org.eclipse.swt.events.ShellEvent e) {
140                 processWindowEvent(swingwt.awt.event.WindowEvent.WINDOW_ICONIFIED);
141             }
142         });
143     }
144     
145 }
146
Popular Tags