Source Code Cross Referenced for PlasticInternalFrameUI.java in  » Swing-Library » jgoodies-looks » com » jgoodies » looks » plastic » 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 » Swing Library » jgoodies looks » com.jgoodies.looks.plastic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2001-2007 JGoodies Karsten Lentzsch. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         * 
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer. 
009:         *     
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution. 
013:         *     
014:         *  o Neither the name of JGoodies Karsten Lentzsch nor the names of 
015:         *    its contributors may be used to endorse or promote products derived 
016:         *    from this software without specific prior written permission. 
017:         *     
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029:         */
030:
031:        package com.jgoodies.looks.plastic;
032:
033:        import java.awt.Color;
034:        import java.awt.Container;
035:        import java.beans.PropertyChangeEvent;
036:        import java.beans.PropertyChangeListener;
037:
038:        import javax.swing.JComponent;
039:        import javax.swing.JInternalFrame;
040:        import javax.swing.LookAndFeel;
041:        import javax.swing.UIManager;
042:        import javax.swing.border.Border;
043:        import javax.swing.border.EmptyBorder;
044:        import javax.swing.plaf.ComponentUI;
045:        import javax.swing.plaf.UIResource;
046:        import javax.swing.plaf.basic.BasicInternalFrameUI;
047:
048:        /**
049:         * The JGoodies Plastic Look and Feel implementation of <code>InternalFrameUI</code>.<p>
050:         * 
051:         * Uses a <code>PlasticInternalFrameTitlePane</code> 
052:         * that in turn uses <code>PlasticTheme</code> colors.<p>
053:         * 
054:         * Although this class is not intended for subclassing, there's no final marker.
055:         * If you extend this class, carefully obey all explicit and implicit 
056:         * constraints made in this class and its superclasses.  
057:         *
058:         * @author  Karsten Lentzsch
059:         * @version $Revision: 1.4 $
060:         */
061:        public class PlasticInternalFrameUI extends BasicInternalFrameUI {
062:
063:            private static final String FRAME_TYPE = "JInternalFrame.frameType";
064:            public static final String IS_PALETTE = "JInternalFrame.isPalette";
065:            private static final String PALETTE_FRAME = "palette";
066:            private static final String OPTION_DIALOG = "optionDialog";
067:            private static final Border EMPTY_BORDER = new EmptyBorder(0, 0, 0,
068:                    0);
069:
070:            private PlasticInternalFrameTitlePane titlePane;
071:            private PropertyChangeListener paletteListener;
072:            private PropertyChangeListener contentPaneListener;
073:
074:            public PlasticInternalFrameUI(JInternalFrame b) {
075:                super (b);
076:            }
077:
078:            public static ComponentUI createUI(JComponent c) {
079:                return new PlasticInternalFrameUI((JInternalFrame) c);
080:            }
081:
082:            public void installUI(JComponent c) {
083:                frame = (JInternalFrame) c;
084:
085:                paletteListener = new PaletteListener(this );
086:                contentPaneListener = new ContentPaneListener(this );
087:                c.addPropertyChangeListener(paletteListener);
088:                c.addPropertyChangeListener(contentPaneListener);
089:
090:                super .installUI(c);
091:
092:                Object paletteProp = c.getClientProperty(IS_PALETTE);
093:                if (paletteProp != null) {
094:                    setPalette(((Boolean) paletteProp).booleanValue());
095:                }
096:
097:                Container content = frame.getContentPane();
098:                stripContentBorder(content);
099:            }
100:
101:            public void uninstallUI(JComponent c) {
102:                frame = (JInternalFrame) c;
103:
104:                c.removePropertyChangeListener(paletteListener);
105:                c.removePropertyChangeListener(contentPaneListener);
106:
107:                Container cont = ((JInternalFrame) (c)).getContentPane();
108:                if (cont instanceof  JComponent) {
109:                    JComponent content = (JComponent) cont;
110:                    if (content.getBorder() == EMPTY_BORDER) {
111:                        content.setBorder(null);
112:                    }
113:                }
114:                super .uninstallUI(c);
115:            }
116:
117:            protected void installDefaults() {
118:                super .installDefaults();
119:
120:                /* Enable the content pane to inherit background color 
121:                 * from its parent by setting its background color to null. 
122:                 * Fixes bug#4268949, which has been fixed in 1.4, too. */
123:                JComponent contentPane = (JComponent) frame.getContentPane();
124:                if (contentPane != null) {
125:                    Color bg = contentPane.getBackground();
126:                    if (bg instanceof  UIResource)
127:                        contentPane.setBackground(null);
128:                }
129:                frame.setBackground(UIManager.getLookAndFeelDefaults()
130:                        .getColor("control"));
131:            }
132:
133:            protected void installKeyboardActions() {
134:            }
135:
136:            protected void uninstallKeyboardActions() {
137:            }
138:
139:            private void stripContentBorder(Object c) {
140:                if (c instanceof  JComponent) {
141:                    JComponent contentComp = (JComponent) c;
142:                    Border contentBorder = contentComp.getBorder();
143:                    if (contentBorder == null
144:                            || contentBorder instanceof  UIResource) {
145:                        contentComp.setBorder(EMPTY_BORDER);
146:                    }
147:                }
148:            }
149:
150:            protected JComponent createNorthPane(JInternalFrame w) {
151:                titlePane = new PlasticInternalFrameTitlePane(w);
152:                return titlePane;
153:            }
154:
155:            public void setPalette(boolean isPalette) {
156:                String key = isPalette ? "InternalFrame.paletteBorder"
157:                        : "InternalFrame.border";
158:                LookAndFeel.installBorder(frame, key);
159:                titlePane.setPalette(isPalette);
160:            }
161:
162:            private void setFrameType(String frameType) {
163:                String key;
164:                boolean hasPalette = frameType.equals(PALETTE_FRAME);
165:                if (frameType.equals(OPTION_DIALOG)) {
166:                    key = "InternalFrame.optionDialogBorder";
167:                } else if (hasPalette) {
168:                    key = "InternalFrame.paletteBorder";
169:                } else {
170:                    key = "InternalFrame.border";
171:                }
172:                LookAndFeel.installBorder(frame, key);
173:                titlePane.setPalette(hasPalette);
174:            }
175:
176:            private static final class PaletteListener implements 
177:                    PropertyChangeListener {
178:
179:                private final PlasticInternalFrameUI ui;
180:
181:                private PaletteListener(PlasticInternalFrameUI ui) {
182:                    this .ui = ui;
183:                }
184:
185:                public void propertyChange(PropertyChangeEvent e) {
186:                    String name = e.getPropertyName();
187:                    Object value = e.getNewValue();
188:                    if (name.equals(FRAME_TYPE)) {
189:                        if (value instanceof  String) {
190:                            ui.setFrameType((String) value);
191:                        }
192:                    } else if (name.equals(IS_PALETTE)) {
193:                        ui.setPalette(Boolean.TRUE.equals(value));
194:                    }
195:                }
196:            }
197:
198:            private static final class ContentPaneListener implements 
199:                    PropertyChangeListener {
200:
201:                private final PlasticInternalFrameUI ui;
202:
203:                private ContentPaneListener(PlasticInternalFrameUI ui) {
204:                    this .ui = ui;
205:                }
206:
207:                public void propertyChange(PropertyChangeEvent e) {
208:                    String name = e.getPropertyName();
209:                    if (name.equals(JInternalFrame.CONTENT_PANE_PROPERTY)) {
210:                        ui.stripContentBorder(e.getNewValue());
211:                    }
212:                }
213:            }
214:
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.