Source Code Cross Referenced for MetalInternalFrameTitlePane.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » plaf » metal » 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.plaf.metal 
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.plaf.metal;
022:
023:        import java.awt.Color;
024:        import java.awt.Container;
025:        import java.awt.Dimension;
026:        import java.awt.Graphics;
027:        import java.awt.LayoutManager;
028:        import java.awt.Rectangle;
029:
030:        import java.beans.PropertyChangeListener;
031:
032:        import javax.swing.BorderFactory;
033:        import javax.swing.Icon;
034:        import javax.swing.JButton;
035:        import javax.swing.JInternalFrame;
036:        import javax.swing.JMenu;
037:        import javax.swing.SwingUtilities;
038:        import javax.swing.UIManager;
039:
040:        import javax.swing.border.Border;
041:        import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
042:
043:        import org.apache.harmony.x.swing.TitlePaneInternals;
044:
045:        public class MetalInternalFrameTitlePane extends
046:                BasicInternalFrameTitlePane {
047:
048:            private class MetalTitlePaneLayout extends TitlePaneLayout {
049:                public Dimension minimumLayoutSize(final Container c) {
050:                    if (!isPalette) {
051:                        return super .minimumLayoutSize(c);
052:                    }
053:
054:                    return new Dimension(43, paletteTitleHeight);
055:                }
056:
057:                public void layoutContainer(final Container c) {
058:                    if (!isPalette) {
059:                        super .layoutContainer(c);
060:                        return;
061:                    }
062:
063:                    // dimensions of the container
064:                    Rectangle inner = SwingUtilities.calculateInnerArea(
065:                            MetalInternalFrameTitlePane.this , null);
066:                    int width = inner.width;
067:                    int height = inner.height;
068:
069:                    // palette can have only "Close" button
070:                    if (frame.isClosable()) {
071:                        int buttonHeight = closeButton.getIcon()
072:                                .getIconHeight();
073:                        int buttonWidth = buttonHeight;
074:                        int x = inner.x + width - buttonWidth;
075:                        int y = inner.y + (height - buttonHeight) / 2;
076:                        closeButton.setBounds(x, y, buttonWidth, buttonHeight);
077:                        inner.width = closeButton.getX() - inner.x
078:                                - internals.gapX;
079:                    }
080:
081:                    internals.decorationR.setBounds(inner);
082:                }
083:            }
084:
085:            protected boolean isPalette;
086:            protected Icon paletteCloseIcon;
087:            protected int paletteTitleHeight;
088:
089:            TitlePaneInternals internals;
090:            Color selectedShadowColor;
091:            Color notSelectedShadowColor;
092:
093:            private Border commonBorder = BorderFactory.createEmptyBorder(3, 0,
094:                    4, 0);
095:            private Border paletteBorder = BorderFactory.createEmptyBorder(1,
096:                    3, 2, 3);
097:
098:            public MetalInternalFrameTitlePane(final JInternalFrame frame) {
099:                super (frame);
100:                setBorder(commonBorder);
101:
102:                installInternals();
103:            }
104:
105:            protected void addSubComponents() {
106:                // overridden to add everything except menu bar,
107:                // but we handle the situation with menuBar == null in the ancestor
108:                super .addSubComponents();
109:            }
110:
111:            protected void addSystemMenuItems(final JMenu menu) {
112:                // do nothing
113:            }
114:
115:            protected void assembleSystemMenu() {
116:                // do nothing
117:            }
118:
119:            protected void showSystemMenu() {
120:                // do nothing
121:            }
122:
123:            protected void createButtons() {
124:                super .createButtons();
125:
126:                setupTitlePaneButton(maxButton,
127:                        "InternalFrameTitlePane.maximizeButtonAccessibleName");
128:                setupTitlePaneButton(iconButton,
129:                        "InternalFrameTitlePane.iconifyButtonAccessibleName");
130:                setupTitlePaneButton(closeButton,
131:                        "InternalFrameTitlePane.closeButtonAccessibleName");
132:            }
133:
134:            private void setupTitlePaneButton(final JButton button,
135:                    final String accessibleNameKey) {
136:                button.getAccessibleContext().setAccessibleName(
137:                        UIManager.getString(accessibleNameKey));
138:                button.setBorderPainted(false);
139:                button.setOpaque(false);
140:                button.setContentAreaFilled(false);
141:            }
142:
143:            protected PropertyChangeListener createPropertyChangeListener() {
144:                // Note: just call the method from super
145:                return super .createPropertyChangeListener();
146:            }
147:
148:            protected LayoutManager createLayout() {
149:                return new MetalTitlePaneLayout();
150:            }
151:
152:            public void paintPalette(final Graphics g) {
153:                g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
154:                g.fillRect(0, 0, getWidth(), getHeight());
155:                paintDecoration(g);
156:                g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
157:                g.drawLine(0, getHeight() - 1, getWidth() - 1, getHeight() - 1);
158:            }
159:
160:            private void paintDecoration(final Graphics g) {
161:                Color shadow = internals.isSelected() ? selectedShadowColor
162:                        : notSelectedShadowColor;
163:                Color highlight = internals.isSelected() ? MetalLookAndFeel
164:                        .getPrimaryControlHighlight() : MetalLookAndFeel
165:                        .getControlHighlight();
166:
167:                MetalBumps.paintBumps(g, internals.decorationR, shadow,
168:                        highlight);
169:            }
170:
171:            public void paintComponent(final Graphics g) {
172:                if (isPalette) {
173:                    paintPalette(g);
174:                    return;
175:                }
176:
177:                super .paintComponent(g);
178:                paintDecoration(g);
179:
180:                // paint the line under the titlePane
181:                g.setColor(internals.isSelected() ? selectedShadowColor
182:                        : notSelectedShadowColor);
183:                g.drawLine(0, getHeight() - 1, getWidth() - 1, getHeight() - 1);
184:            }
185:
186:            public void setPalette(final boolean b) {
187:                isPalette = b;
188:
189:                closeButton.setIcon(isPalette ? paletteCloseIcon : closeIcon);
190:
191:                if (isPalette) {
192:                    setBorder(paletteBorder);
193:                    remove(iconButton);
194:                    remove(maxButton);
195:                } else {
196:                    setBorder(commonBorder);
197:                    if (frame.isIconifiable()) {
198:                        add(iconButton);
199:                    }
200:                    if (frame.isMaximizable()) {
201:                        add(maxButton);
202:                    }
203:                }
204:            }
205:
206:            protected void installDefaults() {
207:                super .installDefaults();
208:
209:                paletteTitleHeight = UIManager
210:                        .getInt("InternalFrame.paletteTitleHeight");
211:                paletteCloseIcon = UIManager
212:                        .getIcon("InternalFrame.paletteCloseIcon");
213:
214:                selectedShadowColor = MetalLookAndFeel
215:                        .getPrimaryControlDarkShadow();
216:                notSelectedShadowColor = MetalLookAndFeel
217:                        .getControlDarkShadow();
218:            }
219:
220:            private void installInternals() {
221:                internals = (TitlePaneInternals) getClientProperty("internals");
222:
223:                internals.decorationR = new Rectangle();
224:                internals.gapX = 6;
225:            }
226:
227:            protected void uninstallDefaults() {
228:                // no need to uninstall anything because
229:                // the title pane is replaced while changing L&F
230:                super .uninstallDefaults();
231:            }
232:
233:            public void addNotify() {
234:                // Note: just call the method from super
235:                super.addNotify();
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.