Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / classpath / javax / swing / JWindow.java
blobcc0ac7fd95ae5f7e11a7557105d75c4f75795800
1 /* JWindow.java --
2 Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.swing;
41 import java.awt.BorderLayout;
42 import java.awt.Component;
43 import java.awt.Container;
44 import java.awt.Dimension;
45 import java.awt.Frame;
46 import java.awt.Graphics;
47 import java.awt.GraphicsConfiguration;
48 import java.awt.LayoutManager;
49 import java.awt.Window;
50 import java.awt.event.KeyEvent;
52 import javax.accessibility.Accessible;
53 import javax.accessibility.AccessibleContext;
55 /**
56 * Unlike JComponent derivatives, JWindow inherits from
57 * java.awt.Window. But also lets a look-and-feel component to its work.
59 * @author Ronald Veldema (rveldema@cs.vu.nl)
61 public class JWindow extends Window implements Accessible, RootPaneContainer
63 /**
64 * Provides accessibility support for <code>JWindow</code>.
66 protected class AccessibleJWindow extends Window.AccessibleAWTWindow
68 /**
69 * Creates a new instance of <code>AccessibleJWindow</code>.
71 public AccessibleJWindow()
73 super();
74 // Nothing to do here.
78 private static final long serialVersionUID = 5420698392125238833L;
80 protected JRootPane rootPane;
82 /**
83 * @specnote rootPaneCheckingEnabled is false to comply with J2SE 5.0
85 protected boolean rootPaneCheckingEnabled = false;
87 protected AccessibleContext accessibleContext;
89 public JWindow()
91 super(SwingUtilities.getOwnerFrame());
92 windowInit();
95 public JWindow(GraphicsConfiguration gc)
97 super(SwingUtilities.getOwnerFrame(), gc);
98 windowInit();
101 public JWindow(Frame owner)
103 super(owner);
104 windowInit();
107 public JWindow(Window owner)
109 super(owner);
110 windowInit();
113 public JWindow(Window owner, GraphicsConfiguration gc)
115 super(owner, gc);
116 windowInit();
119 protected void windowInit()
121 super.setLayout(new BorderLayout(1, 1));
122 getRootPane(); // will do set/create
123 // Now we're done init stage, adds and layouts go to content pane.
124 setRootPaneCheckingEnabled(true);
127 public Dimension getPreferredSize()
129 return super.getPreferredSize();
132 public void setLayout(LayoutManager manager)
134 // Check if we're in initialization stage. If so, call super.setLayout
135 // otherwise, valid calls go to the content pane.
136 if (isRootPaneCheckingEnabled())
137 getContentPane().setLayout(manager);
138 else
139 super.setLayout(manager);
142 public void setLayeredPane(JLayeredPane layeredPane)
144 getRootPane().setLayeredPane(layeredPane);
147 public JLayeredPane getLayeredPane()
149 return getRootPane().getLayeredPane();
152 public JRootPane getRootPane()
154 if (rootPane == null)
155 setRootPane(createRootPane());
156 return rootPane;
159 protected void setRootPane(JRootPane root)
161 if (rootPane != null)
162 remove(rootPane);
164 rootPane = root;
165 add(rootPane, BorderLayout.CENTER);
168 protected JRootPane createRootPane()
170 return new JRootPane();
173 public Container getContentPane()
175 return getRootPane().getContentPane();
178 public void setContentPane(Container contentPane)
180 getRootPane().setContentPane(contentPane);
183 public Component getGlassPane()
185 return getRootPane().getGlassPane();
188 public void setGlassPane(Component glassPane)
190 getRootPane().setGlassPane(glassPane);
194 protected void addImpl(Component comp, Object constraints, int index)
196 // If we're adding in the initialization stage use super.add.
197 // otherwise pass the add onto the content pane.
198 if (isRootPaneCheckingEnabled())
199 getContentPane().add(comp, constraints, index);
200 else
201 super.addImpl(comp, constraints, index);
204 public void remove(Component comp)
206 // If we're removing the root pane, use super.remove. Otherwise
207 // pass it on to the content pane instead.
208 if (comp == rootPane)
209 super.remove(rootPane);
210 else
211 getContentPane().remove(comp);
214 protected boolean isRootPaneCheckingEnabled()
216 return rootPaneCheckingEnabled;
219 protected void setRootPaneCheckingEnabled(boolean enabled)
221 rootPaneCheckingEnabled = enabled;
224 public void update(Graphics g)
226 paint(g);
229 protected void processKeyEvent(KeyEvent e)
231 super.processKeyEvent(e);
234 public AccessibleContext getAccessibleContext()
236 if (accessibleContext == null)
237 accessibleContext = new AccessibleJWindow();
238 return accessibleContext;
241 protected String paramString()
243 return "JWindow";