source: trunk/gcc/libjava/javax/swing/JRootPane.java

Last change on this file was 1389, checked in by bird, 21 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.4 KB
Line 
1/* JRootPane.java --
2 Copyright (C) 2002 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38package javax.swing;
39
40import java.awt.*;
41import java.awt.event.*;
42
43import javax.accessibility.AccessibleContext;
44import javax.accessibility.AccessibleRole;
45import javax.accessibility.AccessibleState;
46import javax.accessibility.AccessibleStateSet;
47
48/**
49 * This class is where JComponents are added to.
50 * Unlike awt where you could just say frame.add(),
51 * with swing you need to say frame.getRootPane()
52 * (which delivers an instance of this class)
53 * and add your components to that.
54 *
55 * It is implemented by several 'layers' (pane() should be read as plane())
56 * each on top of the others
57 * where you can add components to.
58 * (getContentPane(), getGlassPane(), getLayeredPane())
59 *
60 * @author Ronald Veldema (rveldema@cs.vu.nl)
61 */
62public class JRootPane extends JComponent
63{
64 // The class used to obtain the accessible role for this object.
65 static protected class AccessibleJRootPane
66 {
67 }
68
69 //A custom layout manager
70 static protected class RootLayout extends BorderLayout
71 {
72 public Dimension preferredLayoutSize ( Container c )
73 {
74 Dimension p = super.preferredLayoutSize(c);
75 System.out.println(" PREF-SIZE from RootLayout = " + p);
76 return p;
77 }
78 }
79
80 /***********************************************************/
81
82
83 //The glass pane that overlays the menu bar and content pane, so it can intercept mouse movements and such.
84 protected Component glassPane;
85
86 //The layered pane that manages the menu bar and content pane.
87 protected JLayeredPane layeredPane;
88
89 // The menu bar.
90 protected JMenuBar menuBar;
91
92 protected Container contentPane;
93
94 /********************************************************/
95
96 public String getUIClassID()
97 { return "JPanel"; }
98
99
100 void setJMenuBar(JMenuBar m)
101 { menuBar = m; }
102
103 JMenuBar getJMenuBar()
104 { return menuBar; }
105
106
107 public Container getContentPane()
108 {
109 if (contentPane == null)
110 {
111 setContentPane(createContentPane());
112 }
113 return contentPane;
114 }
115
116 public void setContentPane(Container p)
117 {
118 contentPane = p;
119 getLayeredPane().add(contentPane, 0);
120 }
121
122 protected void addImpl(Component comp,
123 Object constraints,
124 int index)
125 {
126 super.addImpl(comp, constraints, index);
127 //System.out.println("don't do that !");
128 }
129
130 public Component getGlassPane()
131 {
132 if (glassPane == null)
133 setGlassPane(createGlassPane());
134 return glassPane;
135 }
136
137 public void setGlassPane(Component f)
138 {
139 if (glassPane != null)
140 remove(glassPane);
141
142 glassPane = f;
143
144 glassPane.setVisible(false);
145 add(glassPane, 0);
146 }
147
148 public JLayeredPane getLayeredPane()
149 {
150 if (layeredPane == null)
151 setLayeredPane(createLayeredPane());
152 return layeredPane;
153 }
154 public void setLayeredPane(JLayeredPane f)
155 {
156 if (layeredPane != null)
157 remove(layeredPane);
158
159 layeredPane = f;
160 add(f, -1);
161 }
162
163
164 /********************************************************/
165
166 JRootPane()
167 {
168 setLayout(createRootLayout());
169
170 getGlassPane();
171 getLayeredPane();
172 getContentPane();
173
174 setDoubleBuffered(true);
175 updateUI();
176 }
177
178 protected LayoutManager createRootLayout() {
179 return new RootLayout();
180 }
181
182 JComponent createContentPane()
183 {
184 JPanel p = new JPanel();
185 p.setName(this.getName()+".contentPane");
186 p.setLayout(new BorderLayout());
187 // p.setVisible(true);
188
189 System.out.println("Created ContentPane: " + p);
190 return p;
191 }
192
193 Component createGlassPane()
194 {
195 JPanel p = new JPanel();
196 p.setName(this.getName()+".glassPane");
197 p.setLayout(new BorderLayout());
198 p.setVisible(false);
199
200 System.out.println("created the glasspane: "+p);
201 return p;
202 }
203
204 JLayeredPane createLayeredPane()
205 {
206 JLayeredPane l = new JLayeredPane();
207 return l;
208 }
209}
Note: See TracBrowser for help on using the repository browser.