Source Code Cross Referenced for SynthInternalFrameUI.java in  » 6.0-JDK-Core » swing » javax » swing » plaf » synth » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing.plaf.synth 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.swing.plaf.synth;
027
028        import java.awt.*;
029        import java.awt.event.*;
030        import java.awt.peer.LightweightPeer;
031
032        import javax.swing.*;
033        import javax.swing.plaf.*;
034        import javax.swing.plaf.basic.BasicInternalFrameUI;
035        import javax.swing.event.*;
036
037        import java.beans.*;
038        import java.io.Serializable;
039        import sun.swing.plaf.synth.SynthUI;
040
041        /**
042         * Synth's InternalFrameUI.
043         *
044         * @version 1.28 05/05/07
045         * @author David Kloba
046         * @author Joshua Outwater
047         * @author Rich Schiavi
048         */
049        class SynthInternalFrameUI extends BasicInternalFrameUI implements 
050                SynthUI, PropertyChangeListener {
051            private SynthStyle style;
052
053            private static DesktopManager sharedDesktopManager;
054            private boolean componentListenerAdded = false;
055
056            private Rectangle parentBounds;
057
058            public static ComponentUI createUI(JComponent b) {
059                return new SynthInternalFrameUI((JInternalFrame) b);
060            }
061
062            public SynthInternalFrameUI(JInternalFrame b) {
063                super (b);
064            }
065
066            public void installDefaults() {
067                frame.setLayout(internalFrameLayout = createLayoutManager());
068                updateStyle(frame);
069            }
070
071            protected void installListeners() {
072                super .installListeners();
073                frame.addPropertyChangeListener(this );
074            }
075
076            protected void uninstallComponents() {
077                if (frame.getComponentPopupMenu() instanceof  UIResource) {
078                    frame.setComponentPopupMenu(null);
079                }
080                super .uninstallComponents();
081            }
082
083            protected void uninstallListeners() {
084                frame.removePropertyChangeListener(this );
085                super .uninstallListeners();
086            }
087
088            private void updateStyle(JComponent c) {
089                SynthContext context = getContext(c, ENABLED);
090                SynthStyle oldStyle = style;
091
092                style = SynthLookAndFeel.updateStyle(context, this );
093                if (style != oldStyle) {
094                    Icon frameIcon = frame.getFrameIcon();
095                    if (frameIcon == null || frameIcon instanceof  UIResource) {
096                        frame.setFrameIcon(context.getStyle().getIcon(context,
097                                "InternalFrame.icon"));
098                    }
099                    if (oldStyle != null) {
100                        uninstallKeyboardActions();
101                        installKeyboardActions();
102                    }
103                }
104                context.dispose();
105            }
106
107            protected void uninstallDefaults() {
108                SynthContext context = getContext(frame, ENABLED);
109                style.uninstallDefaults(context);
110                context.dispose();
111                style = null;
112                if (frame.getLayout() == internalFrameLayout) {
113                    frame.setLayout(null);
114                }
115
116            }
117
118            public SynthContext getContext(JComponent c) {
119                return getContext(c, getComponentState(c));
120            }
121
122            private SynthContext getContext(JComponent c, int state) {
123                return SynthContext.getContext(SynthContext.class, c,
124                        SynthLookAndFeel.getRegion(c), style, state);
125            }
126
127            private Region getRegion(JComponent c) {
128                return SynthLookAndFeel.getRegion(c);
129            }
130
131            public int getComponentState(JComponent c) {
132                return SynthLookAndFeel.getComponentState(c);
133            }
134
135            protected JComponent createNorthPane(JInternalFrame w) {
136                titlePane = new SynthInternalFrameTitlePane(w);
137                titlePane.setName("InternalFrame.northPane");
138                return titlePane;
139            }
140
141            protected ComponentListener createComponentListener() {
142                if (UIManager.getBoolean("InternalFrame.useTaskBar")) {
143                    return new ComponentHandler() {
144                        public void componentResized(ComponentEvent e) {
145                            if (frame != null && frame.isMaximum()) {
146                                JDesktopPane desktop = (JDesktopPane) e
147                                        .getSource();
148                                for (Component comp : desktop.getComponents()) {
149                                    if (comp instanceof  SynthDesktopPaneUI.TaskBar) {
150                                        frame.setBounds(0, 0, desktop
151                                                .getWidth(), desktop
152                                                .getHeight()
153                                                - comp.getHeight());
154                                        frame.revalidate();
155                                        break;
156                                    }
157                                }
158                            }
159
160                            // Update the new parent bounds for next resize, but don't
161                            // let the super method touch this frame
162                            JInternalFrame f = frame;
163                            frame = null;
164                            super .componentResized(e);
165                            frame = f;
166                        }
167                    };
168                } else {
169                    return super .createComponentListener();
170                }
171            }
172
173            public void update(Graphics g, JComponent c) {
174                SynthContext context = getContext(c);
175
176                SynthLookAndFeel.update(context, g);
177                context.getPainter().paintInternalFrameBackground(context, g,
178                        0, 0, c.getWidth(), c.getHeight());
179                paint(context, g);
180                context.dispose();
181            }
182
183            public void paint(Graphics g, JComponent c) {
184                SynthContext context = getContext(c);
185
186                paint(context, g);
187                context.dispose();
188            }
189
190            protected void paint(SynthContext context, Graphics g) {
191            }
192
193            public void paintBorder(SynthContext context, Graphics g, int x,
194                    int y, int w, int h) {
195                context.getPainter().paintInternalFrameBorder(context, g, x, y,
196                        w, h);
197            }
198
199            public void propertyChange(PropertyChangeEvent evt) {
200                SynthStyle oldStyle = style;
201                JInternalFrame f = (JInternalFrame) evt.getSource();
202                String prop = evt.getPropertyName();
203
204                if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
205                    updateStyle(f);
206                }
207
208                if (style == oldStyle
209                        && (prop == JInternalFrame.IS_MAXIMUM_PROPERTY || prop == JInternalFrame.IS_SELECTED_PROPERTY)) {
210                    // Border (and other defaults) may need to change
211                    SynthContext context = getContext(f, ENABLED);
212                    style.uninstallDefaults(context);
213                    style.installDefaults(context, this);
214                }
215            }
216        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.