1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51:
52: import ;
53: import ;
54:
55:
61: public class JWindow extends Window implements Accessible, RootPaneContainer
62: {
63:
66: protected class AccessibleJWindow extends Window.AccessibleAWTWindow
67: {
68:
71: public AccessibleJWindow()
72: {
73: super();
74:
75: }
76: }
77:
78: private static final long serialVersionUID = 5420698392125238833L;
79:
80: protected JRootPane rootPane;
81:
82:
85: protected boolean rootPaneCheckingEnabled = false;
86:
87: protected AccessibleContext accessibleContext;
88:
89: public JWindow()
90: {
91: super(SwingUtilities.getOwnerFrame());
92: windowInit();
93: }
94:
95: public JWindow(GraphicsConfiguration gc)
96: {
97: super(SwingUtilities.getOwnerFrame(), gc);
98: windowInit();
99: }
100:
101: public JWindow(Frame owner)
102: {
103: super(owner);
104: windowInit();
105: }
106:
107: public JWindow(Window owner)
108: {
109: super(owner);
110: windowInit();
111: }
112:
113: public JWindow(Window owner, GraphicsConfiguration gc)
114: {
115: super(owner, gc);
116: windowInit();
117: }
118:
119: protected void windowInit()
120: {
121: super.setLayout(new BorderLayout(1, 1));
122: getRootPane();
123:
124: setRootPaneCheckingEnabled(true);
125: }
126:
127: public Dimension getPreferredSize()
128: {
129: return super.getPreferredSize();
130: }
131:
132: public void setLayout(LayoutManager manager)
133: {
134:
135:
136: if (isRootPaneCheckingEnabled())
137: getContentPane().setLayout(manager);
138: else
139: super.setLayout(manager);
140: }
141:
142: public void setLayeredPane(JLayeredPane layeredPane)
143: {
144: getRootPane().setLayeredPane(layeredPane);
145: }
146:
147: public JLayeredPane getLayeredPane()
148: {
149: return getRootPane().getLayeredPane();
150: }
151:
152: public JRootPane getRootPane()
153: {
154: if (rootPane == null)
155: setRootPane(createRootPane());
156: return rootPane;
157: }
158:
159: protected void setRootPane(JRootPane root)
160: {
161: if (rootPane != null)
162: remove(rootPane);
163:
164: rootPane = root;
165: add(rootPane, BorderLayout.CENTER);
166: }
167:
168: protected JRootPane createRootPane()
169: {
170: return new JRootPane();
171: }
172:
173: public Container getContentPane()
174: {
175: return getRootPane().getContentPane();
176: }
177:
178: public void setContentPane(Container contentPane)
179: {
180: getRootPane().setContentPane(contentPane);
181: }
182:
183: public Component getGlassPane()
184: {
185: return getRootPane().getGlassPane();
186: }
187:
188: public void setGlassPane(Component glassPane)
189: {
190: getRootPane().setGlassPane(glassPane);
191: }
192:
193:
194: protected void addImpl(Component comp, Object constraints, int index)
195: {
196:
197:
198: if (isRootPaneCheckingEnabled())
199: getContentPane().add(comp, constraints, index);
200: else
201: super.addImpl(comp, constraints, index);
202: }
203:
204: public void remove(Component comp)
205: {
206:
207:
208: if (comp == rootPane)
209: super.remove(rootPane);
210: else
211: getContentPane().remove(comp);
212: }
213:
214: protected boolean isRootPaneCheckingEnabled()
215: {
216: return rootPaneCheckingEnabled;
217: }
218:
219: protected void setRootPaneCheckingEnabled(boolean enabled)
220: {
221: rootPaneCheckingEnabled = enabled;
222: }
223:
224: public void update(Graphics g)
225: {
226: paint(g);
227: }
228:
229: protected void processKeyEvent(KeyEvent e)
230: {
231: super.processKeyEvent(e);
232: }
233:
234: public AccessibleContext getAccessibleContext()
235: {
236: if (accessibleContext == null)
237: accessibleContext = new AccessibleJWindow();
238: return accessibleContext;
239: }
240:
241: protected String paramString()
242: {
243: return "JWindow";
244: }
245: }