Source Code Cross Referenced for BasicInternalFrameUI$InternalFrameLayoutTest.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » plaf » basic » 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.basic 
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:         * @author Vadim L. Bogdanov
019:         * @version $Revision$
020:         */package javax.swing.plaf.basic;
021:
022:        import java.awt.Dimension;
023:        import java.awt.LayoutManager;
024:        import java.awt.Rectangle;
025:        import javax.swing.BorderFactory;
026:        import javax.swing.JComponent;
027:        import javax.swing.JInternalFrame;
028:        import javax.swing.JPanel;
029:        import javax.swing.SwingTestCase;
030:
031:        /**
032:         * Test BasicInternalFrameUI.InternalFrameLayout class
033:         *
034:         */
035:        public class BasicInternalFrameUI$InternalFrameLayoutTest extends
036:                SwingTestCase {
037:            private JInternalFrame frame;
038:
039:            private BasicInternalFrameUI ui;
040:
041:            private LayoutManager layout;
042:
043:            private JComponent titlePane;
044:
045:            @Override
046:            protected void setUp() throws Exception {
047:                super .setUp();
048:                frame = new JInternalFrame();
049:                frame.setBorder(BorderFactory.createEmptyBorder(5, 10, 15, 20));
050:                ui = new BasicInternalFrameUI(frame);
051:                frame.setUI(ui);
052:                layout = frame.getLayout();
053:                titlePane = (JComponent) frame.getComponent(1);
054:                titlePane.setPreferredSize(new Dimension(100, 20));
055:                titlePane.setMinimumSize(new Dimension(80, 10));
056:            }
057:
058:            @Override
059:            protected void tearDown() throws Exception {
060:                titlePane = null;
061:                ui = null;
062:                layout = null;
063:                frame.dispose();
064:                frame = null;
065:                super .tearDown();
066:            }
067:
068:            public void testPreferredLayoutSize() {
069:                Dimension rootPanePreferredSize = new Dimension(32, 21);
070:                frame.getRootPane().setPreferredSize(rootPanePreferredSize);
071:                // only northPane is set
072:                // 1.5 seems to add Insests before calculating max between TitlePane width
073:                // and RootPane width which is likely a bug.
074:                if (isHarmony()) {
075:                    assertEquals("1 pane", new Dimension(130, 61), layout
076:                            .preferredLayoutSize(frame));
077:                } else {
078:                    assertEquals("1 pane", new Dimension(100, 61), layout
079:                            .preferredLayoutSize(frame));
080:                }
081:                assertEquals("rootPane's preferred size not changed",
082:                        rootPanePreferredSize, frame.getRootPane()
083:                                .getPreferredSize());
084:                titlePane.setPreferredSize(new Dimension(10, 20));
085:                assertEquals("1 pane", new Dimension(62, 61), layout
086:                        .preferredLayoutSize(frame));
087:                assertEquals("rootPane's preferred size not changed",
088:                        rootPanePreferredSize, frame.getRootPane()
089:                                .getPreferredSize());
090:                // all panes are set
091:                ui.getNorthPane().setPreferredSize(new Dimension(14, 18));
092:                ui.setWestPane(new JPanel());
093:                ui.getWestPane().setPreferredSize(new Dimension(11, 22));
094:                ui.setSouthPane(new JPanel());
095:                ui.getSouthPane().setPreferredSize(new Dimension(12, 23));
096:                ui.setEastPane(new JPanel());
097:                ui.getEastPane().setPreferredSize(new Dimension(13, 24));
098:                assertEquals("all panes", new Dimension(86, 82), layout
099:                        .preferredLayoutSize(frame));
100:            }
101:
102:            /*
103:             * Class under test for Dimension minimumLayoutSize(Container)
104:             */
105:            public void testMinimumLayoutSize() {
106:                frame.getRootPane().setMinimumSize(new Dimension(32, 21));
107:                // only northPane is set
108:                assertEquals("1 pane", new Dimension(110, 30), layout
109:                        .minimumLayoutSize(frame));
110:                // all panes are set
111:                ui.getNorthPane().setMinimumSize(new Dimension(14, 18));
112:                ui.setWestPane(new JPanel());
113:                ui.getWestPane().setMinimumSize(new Dimension(11, 22));
114:                ui.setSouthPane(new JPanel());
115:                ui.getSouthPane().setMinimumSize(new Dimension(12, 23));
116:                ui.setEastPane(new JPanel());
117:                ui.getEastPane().setMinimumSize(new Dimension(13, 24));
118:                assertEquals("all panes", new Dimension(44, 38), layout
119:                        .minimumLayoutSize(frame));
120:            }
121:
122:            /*
123:             * Class under test for void layoutContainer(Container)
124:             */
125:            public void testLayoutContainer() {
126:                frame.getRootPane().setPreferredSize(new Dimension(9, 21));
127:                frame.setSize(100, 200);
128:                // only northPane is set
129:                layout.layoutContainer(frame);
130:                assertEquals(new Rectangle(10, 25, 70, 160), frame
131:                        .getRootPane().getBounds());
132:                assertEquals(new Rectangle(10, 5, 70, 20), ui.getNorthPane()
133:                        .getBounds());
134:                // all panes are set
135:                JPanel button = new JPanel();
136:                button.setPreferredSize(new Dimension(11, 12));
137:                ui.setWestPane(button);
138:                button = new JPanel();
139:                button.setPreferredSize(new Dimension(11, 12));
140:                ui.setSouthPane(button);
141:                button = new JPanel();
142:                button.setPreferredSize(new Dimension(11, 12));
143:                ui.setEastPane(button);
144:                layout.layoutContainer(frame);
145:                assertEquals(new Rectangle(21, 25, 48, 148), frame
146:                        .getRootPane().getBounds());
147:                assertEquals(new Rectangle(10, 5, 70, 20), ui.getNorthPane()
148:                        .getBounds());
149:                assertEquals(new Rectangle(10, 25, 11, 148), ui.getWestPane()
150:                        .getBounds());
151:                assertEquals(new Rectangle(10, 173, 70, 12), ui.getSouthPane()
152:                        .getBounds());
153:                // 1.5 fails because of its bug in layout
154:                if (isHarmony()) {
155:                    assertEquals(new Rectangle(69, 25, 11, 148), ui
156:                            .getEastPane().getBounds());
157:                } else {
158:                    assertEquals(new Rectangle(48, 25, 11, 148), ui
159:                            .getEastPane().getBounds());
160:                }
161:            }
162:
163:            /*
164:             * Class under test for void addLayoutComponent(String, Component)
165:             */
166:            public void testAddLayoutComponent() {
167:                JPanel button = new JPanel();
168:                layout.addLayoutComponent("ok", button);
169:                assertFalse("not added", frame.isAncestorOf(button));
170:            }
171:
172:            /*
173:             * Class under test for void removeLayoutComponent(Component)
174:             */
175:            public void testRemoveLayoutComponent() {
176:                layout.layoutContainer(frame);
177:                Rectangle bounds = frame.getRootPane().getBounds();
178:                layout.removeLayoutComponent(ui.getNorthPane());
179:                layout.layoutContainer(frame);
180:                assertEquals("nothing changed", bounds, frame.getRootPane()
181:                        .getBounds());
182:            }
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.