Source Code Cross Referenced for JRootPane.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » javax package » javax.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        /**
019:         * @author Vadim L. Bogdanov
020:         * @version $Revision$
021:         */package javax.swing;
022:
023:        import java.awt.BorderLayout;
024:        import java.awt.Component;
025:        import java.awt.Container;
026:        import java.awt.Dimension;
027:        import java.awt.IllegalComponentStateException;
028:        import java.awt.LayoutManager;
029:        import java.awt.LayoutManager2;
030:        import java.awt.Rectangle;
031:
032:        import java.awt.event.ActionEvent;
033:
034:        import java.io.Serializable;
035:
036:        import javax.accessibility.Accessible;
037:        import javax.accessibility.AccessibleContext;
038:        import javax.accessibility.AccessibleRole;
039:
040:        import javax.swing.plaf.RootPaneUI;
041:
042:        import org.apache.harmony.x.swing.Utilities;
043:
044:        public class JRootPane extends JComponent implements  Accessible {
045:            public static final int NONE = 0;
046:            public static final int FRAME = 1;
047:            public static final int PLAIN_DIALOG = 2;
048:            public static final int INFORMATION_DIALOG = 3;
049:            public static final int ERROR_DIALOG = 4;
050:            public static final int COLOR_CHOOSER_DIALOG = 5;
051:            public static final int FILE_CHOOSER_DIALOG = 6;
052:            public static final int QUESTION_DIALOG = 7;
053:            public static final int WARNING_DIALOG = 8;
054:
055:            protected JMenuBar menuBar;
056:            protected Container contentPane;
057:            protected JLayeredPane layeredPane;
058:            protected Component glassPane;
059:            protected JButton defaultButton;
060:
061:            /**
062:             * @deprecated
063:             */
064:            protected DefaultAction defaultPressAction;
065:
066:            /**
067:             * @deprecated
068:             */
069:            protected DefaultAction defaultReleaseAction;
070:
071:            private int windowDecorationStyle = NONE;
072:            private JButton savedDefaultButton;
073:
074:            public JRootPane() {
075:                setGlassPane(createGlassPane());
076:                setLayeredPane(createLayeredPane());
077:                setContentPane(createContentPane());
078:                setLayout(createRootLayout());
079:                setDoubleBuffered(true);
080:
081:                updateUI();
082:            }
083:
084:            /**
085:             * This class implements accessibility support for <code>JRootPane</code>.
086:             */
087:            protected class AccessibleJRootPane extends AccessibleJComponent {
088:                protected AccessibleJRootPane() {
089:                }
090:
091:                public AccessibleRole getAccessibleRole() {
092:                    return AccessibleRole.ROOT_PANE;
093:                }
094:
095:                public int getAccessibleChildrenCount() {
096:                    // not sure
097:                    return 1;
098:                }
099:
100:                public Accessible getAccessibleChild(final int i) {
101:                    // not sure
102:                    return (Accessible) contentPane;
103:                }
104:            }
105:
106:            protected class RootLayout implements  LayoutManager2, Serializable {
107:                protected RootLayout() {
108:                }
109:
110:                public Dimension preferredLayoutSize(final Container parent) {
111:                    return Utilities.getRootPaneLayoutSize(getContentPane()
112:                            .getPreferredSize(),
113:                            getJMenuBar() != null ? getJMenuBar()
114:                                    .getPreferredSize() : null, null,
115:                            getInsets());
116:                }
117:
118:                public Dimension minimumLayoutSize(final Container parent) {
119:                    return Utilities
120:                            .getRootPaneLayoutSize(getContentPane()
121:                                    .getMinimumSize(),
122:                                    getJMenuBar() != null ? getJMenuBar()
123:                                            .getMinimumSize() : null, null,
124:                                    getInsets());
125:                }
126:
127:                public Dimension maximumLayoutSize(final Container target) {
128:                    return Utilities
129:                            .getRootPaneLayoutSize(getContentPane()
130:                                    .getMaximumSize(),
131:                                    getJMenuBar() != null ? getJMenuBar()
132:                                            .getMaximumSize() : null, null,
133:                                    getInsets());
134:                }
135:
136:                public void layoutContainer(final Container parent) {
137:                    //The glassPane fills the entire viewable area of the JRootPane (bounds - insets).
138:                    //The layeredPane fills the entire viewable area of the JRootPane. (bounds - insets)
139:                    //The menuBar is positioned at the upper edge of the layeredPane.
140:                    //The contentPane fills the entire viewable area, minus the menuBar, if present.
141:                    JRootPane root = (JRootPane) parent;
142:                    Rectangle r = SwingUtilities.calculateInnerArea(root, null);
143:
144:                    root.getGlassPane().setBounds(r);
145:                    root.getLayeredPane().setBounds(r);
146:
147:                    // menuBar, contentPane lay in layeredPane
148:                    int top = 0;
149:                    int height = r.height;
150:                    if (root.getJMenuBar() != null) {
151:                        int menuHeight = root.getJMenuBar().getPreferredSize().height;
152:                        // menuBar lays in layeredPane
153:                        root.getJMenuBar().setBounds(0, 0, r.width, menuHeight);
154:                        top = menuHeight;
155:                        height -= menuHeight;
156:                    }
157:                    // contentPane lays in layeredPane
158:                    root.getContentPane().setBounds(0, top, r.width, height);
159:                }
160:
161:                public void addLayoutComponent(final String name,
162:                        final Component comp) {
163:                    // this method is not used
164:                }
165:
166:                public void removeLayoutComponent(final Component comp) {
167:                    // this method is not used
168:                }
169:
170:                public void addLayoutComponent(final Component comp,
171:                        final Object constraints) {
172:                    // this method is not used
173:                }
174:
175:                public float getLayoutAlignmentX(final Container target) {
176:                    return 0;
177:                }
178:
179:                public float getLayoutAlignmentY(final Container target) {
180:                    return 0;
181:                }
182:
183:                public void invalidateLayout(final Container target) {
184:                    // this method is not used
185:                }
186:            }
187:
188:            /*
189:             * This is deprecate functionality and the class is private.
190:             * No implmenentation is required.
191:             */
192:            private class DefaultAction extends AbstractAction {
193:                private DefaultAction() {
194:                }
195:
196:                public void actionPerformed(final ActionEvent e) {
197:                }
198:            }
199:
200:            public void setUI(final RootPaneUI newUI) {
201:                super .setUI(newUI);
202:            }
203:
204:            public RootPaneUI getUI() {
205:                return (RootPaneUI) ui;
206:            }
207:
208:            public void updateUI() {
209:                setUI((RootPaneUI) UIManager.getUI(this ));
210:            }
211:
212:            public String getUIClassID() {
213:                return "RootPaneUI";
214:            }
215:
216:            public int getWindowDecorationStyle() {
217:                return windowDecorationStyle;
218:            }
219:
220:            public void setWindowDecorationStyle(
221:                    final int newWindowDecorationStyle) {
222:                switch (newWindowDecorationStyle) {
223:                case NONE:
224:                case FRAME:
225:                case PLAIN_DIALOG:
226:                case INFORMATION_DIALOG:
227:                case ERROR_DIALOG:
228:                case COLOR_CHOOSER_DIALOG:
229:                case FILE_CHOOSER_DIALOG:
230:                case QUESTION_DIALOG:
231:                case WARNING_DIALOG:
232:                    int oldWindowDecorationStyle = windowDecorationStyle;
233:                    windowDecorationStyle = newWindowDecorationStyle;
234:                    firePropertyChange("windowDecorationStyle",
235:                            oldWindowDecorationStyle, newWindowDecorationStyle);
236:                    return;
237:                }
238:                throw new IllegalArgumentException();
239:            }
240:
241:            /**
242:             * @deprecated
243:             */
244:            public void setMenuBar(final JMenuBar menu) {
245:                setJMenuBar(menu);
246:            }
247:
248:            public void setJMenuBar(final JMenuBar menu) {
249:                if (getJMenuBar() != null) {
250:                    layeredPane.remove(getJMenuBar());
251:                }
252:                if (menu != null) {
253:                    layeredPane.add(menu, JLayeredPane.FRAME_CONTENT_LAYER);
254:                }
255:                menuBar = menu;
256:            }
257:
258:            /**
259:             * @deprecated
260:             */
261:            public JMenuBar getMenuBar() {
262:                return getJMenuBar();
263:            }
264:
265:            public JMenuBar getJMenuBar() {
266:                return menuBar;
267:            }
268:
269:            protected JLayeredPane createLayeredPane() {
270:                JLayeredPane panel = new JLayeredPane();
271:                panel.setName("layeredPane");
272:                return panel;
273:            }
274:
275:            protected Container createContentPane() {
276:                //return super.createContentPane();
277:                JPanel panel = new JPanel(new BorderLayout());
278:                panel.setName("contentPane");
279:                panel.setOpaque(true);
280:                return panel;
281:            }
282:
283:            protected Component createGlassPane() {
284:                JPanel panel = new JPanel(false); // double buffering is set to false
285:                panel.setName("glassPane");
286:                panel.setVisible(false);
287:                panel.setOpaque(false);
288:                return panel;
289:            }
290:
291:            public Container getContentPane() {
292:                return contentPane;
293:            }
294:
295:            public void setContentPane(final Container content) {
296:                if (content == null) {
297:                    throw new IllegalComponentStateException();
298:                }
299:                if (getContentPane() != null) {
300:                    layeredPane.remove(getContentPane());
301:                }
302:                layeredPane.add(content, JLayeredPane.FRAME_CONTENT_LAYER);
303:                contentPane = content;
304:            }
305:
306:            public void setLayeredPane(final JLayeredPane layered) {
307:                if (layered == null) {
308:                    throw new IllegalComponentStateException();
309:                }
310:                if (getLayeredPane() != null) {
311:                    remove(getLayeredPane());
312:                }
313:                add(layered);
314:                layeredPane = layered;
315:            }
316:
317:            public JLayeredPane getLayeredPane() {
318:                return layeredPane;
319:            }
320:
321:            public void setGlassPane(final Component glass) {
322:                if (glass == null) {
323:                    throw new NullPointerException();
324:                }
325:                if (getGlassPane() != null) {
326:                    remove(getGlassPane());
327:                }
328:                glassPane = glass;
329:                add(glass);
330:            }
331:
332:            public Component getGlassPane() {
333:                return glassPane;
334:            }
335:
336:            protected void addImpl(final Component comp,
337:                    final Object constraints, final int index) {
338:                if (comp == getGlassPane()) {
339:                    //          glassPane should always has a position 0
340:                    super .addImpl(comp, constraints, 0);
341:                } else if (index == 0) {
342:                    //          not a glass pane, index cannot be 0
343:                    super .addImpl(comp, constraints, 1);
344:                } else {
345:                    super .addImpl(comp, constraints, index);
346:                }
347:            }
348:
349:            public boolean isValidateRoot() {
350:                return true;
351:            }
352:
353:            public boolean isOptimizedDrawingEnabled() {
354:                return !getGlassPane().isVisible();
355:            }
356:
357:            protected String paramString() {
358:                return super .paramString();
359:            }
360:
361:            protected LayoutManager createRootLayout() {
362:                return new RootLayout();
363:            }
364:
365:            public void setDefaultButton(final JButton button) {
366:                JButton oldButton = defaultButton;
367:                defaultButton = button;
368:                savedDefaultButton = button;
369:                firePropertyChange("defaultButton", oldButton, button);
370:            }
371:
372:            public JButton getDefaultButton() {
373:                return defaultButton;
374:            }
375:
376:            /**
377:             * Returns the accessible context for the root pane.
378:             *
379:             * @return the accessible context for the root pane
380:             */
381:            public AccessibleContext getAccessibleContext() {
382:                if (accessibleContext == null) {
383:                    accessibleContext = new AccessibleJRootPane();
384:                }
385:
386:                return accessibleContext;
387:            }
388:
389:            public void removeNotify() {
390:                JButton lastDefaultButton = getDefaultButton();
391:                super .removeNotify();
392:                savedDefaultButton = lastDefaultButton;
393:            }
394:
395:            public void addNotify() {
396:                super.addNotify();
397:                if (getDefaultButton() == null && savedDefaultButton != null
398:                        && savedDefaultButton.getRootPane() == this) {
399:                    setDefaultButton(savedDefaultButton);
400:                }
401:            }
402:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.