Source Code Cross Referenced for CompoundBorderTest.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » border » 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.border 
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 Alexander T. Simbirtsev
019:         * @version $Revision$
020:         * Created on 01.12.2004
021:
022:         */package javax.swing.border;
023:
024:        import java.awt.Color;
025:        import java.awt.Insets;
026:        import javax.swing.JPanel;
027:        import javax.swing.SwingTestCase;
028:
029:        public class CompoundBorderTest extends SwingTestCase {
030:            /*
031:             * Class under test for Insets getBorderInsets(Component, Insets)
032:             */
033:            public void testGetBorderInsetsComponentInsets() {
034:                LineBorder border1 = new LineBorder(Color.red, 10, false);
035:                LineBorder border2 = new LineBorder(Color.red, 3, false);
036:                CompoundBorder border4 = new CompoundBorder(border1, border2);
037:                Insets insets = new Insets(1, 1, 1, 1);
038:                JPanel panel = new JPanel();
039:                panel.setBorder(new LineBorder(Color.black, 10001));
040:                border4.getBorderInsets(panel, insets);
041:                assertEquals("insets values coincide", 13, insets.top);
042:                assertEquals("insets values coincide", 13, insets.left);
043:                assertEquals("insets values coincide", 13, insets.right);
044:                assertEquals("insets values coincide", 13, insets.bottom);
045:                insets = new Insets(1001, 1002, 1003, 1004);
046:                panel.setBorder(new LineBorder(Color.black, 100001));
047:                Insets newInsets = border4.getBorderInsets(panel, insets);
048:                assertEquals("insets values coincide", 13, newInsets.top);
049:                assertEquals("insets values coincide", 13, newInsets.left);
050:                assertEquals("insets values coincide", 13, newInsets.right);
051:                assertEquals("insets values coincide", 13, newInsets.bottom);
052:                assertEquals("insets values coincide", 13, insets.top);
053:                assertEquals("insets values coincide", 13, insets.left);
054:                assertEquals("insets values coincide", 13, insets.right);
055:                assertEquals("insets values coincide", 13, insets.bottom);
056:            }
057:
058:            /*
059:             * Class under test for Insets getBorderInsets(Component)
060:             */
061:            public void testGetBorderInsetsComponent() {
062:                LineBorder border1 = new LineBorder(Color.red, 10, false);
063:                LineBorder border2 = new LineBorder(Color.red, 3, false);
064:                EmptyBorder border3 = new EmptyBorder(101, 102, 103, 104);
065:                CompoundBorder border4 = new CompoundBorder(border1, border2);
066:                CompoundBorder border5 = new CompoundBorder(border2, border3);
067:                CompoundBorder border6 = new CompoundBorder();
068:                CompoundBorder border7 = new CompoundBorder(border2, null);
069:                CompoundBorder border8 = new CompoundBorder(null, border3);
070:                Insets insets1 = new Insets(13, 13, 13, 13);
071:                Insets insets2 = new Insets(104, 105, 106, 107);
072:                Insets insets3 = new Insets(0, 0, 0, 0);
073:                Insets insets4 = new Insets(3, 3, 3, 3);
074:                Insets insets5 = new Insets(101, 102, 103, 104);
075:                JPanel panel = new JPanel();
076:                panel.setBorder(new EmptyBorder(1000, 1001, 1002, 1003));
077:                assertEquals("Insets coincide ", insets1, border4
078:                        .getBorderInsets(null));
079:                assertEquals("Insets coincide ", insets1, border4
080:                        .getBorderInsets(panel));
081:                assertEquals("Insets coincide ", insets2, border5
082:                        .getBorderInsets(null));
083:                assertEquals("Insets coincide ", insets2, border5
084:                        .getBorderInsets(panel));
085:                assertEquals("Insets coincide ", insets3, border6
086:                        .getBorderInsets(null));
087:                assertEquals("Insets coincide ", insets3, border6
088:                        .getBorderInsets(panel));
089:                assertEquals("Insets coincide ", insets4, border7
090:                        .getBorderInsets(null));
091:                assertEquals("Insets coincide ", insets4, border7
092:                        .getBorderInsets(panel));
093:                assertEquals("Insets coincide ", insets5, border8
094:                        .getBorderInsets(null));
095:                assertEquals("Insets coincide ", insets5, border8
096:                        .getBorderInsets(panel));
097:            }
098:
099:            public void testPaintBorder() {
100:                //        JPanel panel1 = new JPanel();
101:                //        JPanel panel2 = new JPanel();
102:                //        JPanel panel3 = new JPanel();
103:                //        JPanel panel4 = new JPanel();
104:                //
105:                //        LineBorder border1 = new LineBorder(Color.red, 10, false);
106:                //        LineBorder border2 = new LineBorder(Color.yellow, 30, true);
107:                //        CompoundBorder border3 = new CompoundBorder(border1, border2);
108:                //        CompoundBorder border4 = new CompoundBorder(null, border2);
109:                //        CompoundBorder border5 = new CompoundBorder(border1, null);
110:                //        panel2.setBorder(border3);
111:                //        panel3.setBorder(border4);
112:                //        panel4.setBorder(border5);
113:                //        panel2.setPreferredSize(new Dimension(200, 150));
114:                //        panel3.setPreferredSize(new Dimension(200, 150));
115:                //        panel4.setPreferredSize(new Dimension(200, 150));
116:                //
117:                //        panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));
118:                //        panel1.add(panel2);
119:                //        panel1.add(panel3);
120:                //        panel1.add(panel4);
121:                //
122:                //        JFrame frame = new JFrame();
123:                //        frame.getContentPane().add(panel1);
124:                //        frame.pack();
125:                //        frame.show();
126:                //        while(!frame.isActive());
127:                //        while(frame.isActive());
128:            }
129:
130:            public void testIsBorderOpaque() {
131:                LineBorder border1 = new LineBorder(Color.red, 33, false);
132:                LineBorder border2 = new LineBorder(Color.red, 33, false);
133:                EmptyBorder border3 = new EmptyBorder(1, 1, 1, 1);
134:                CompoundBorder border4 = new CompoundBorder(border1, border2);
135:                CompoundBorder border5 = new CompoundBorder(border2, border3);
136:                CompoundBorder border6 = new CompoundBorder();
137:                CompoundBorder border7 = new CompoundBorder(border2, null);
138:                CompoundBorder border8 = new CompoundBorder(null, border3);
139:                assertTrue("This border is opaque", border4.isBorderOpaque());
140:                assertFalse("This border is not opaque", border5
141:                        .isBorderOpaque());
142:                assertTrue("This border is opaque", border6.isBorderOpaque());
143:                assertTrue("This border is opaque", border7.isBorderOpaque());
144:                assertFalse("This border is not opaque", border8
145:                        .isBorderOpaque());
146:            }
147:
148:            /*
149:             * Class under test for void CompoundBorder(Border, Border)
150:             */
151:            public void testCompoundBorderBorderBorder() {
152:                LineBorder border1 = new LineBorder(Color.red, 33, false);
153:                LineBorder border2 = new LineBorder(Color.red, 33, true);
154:                EmptyBorder border3 = new EmptyBorder(1, 1, 1, 1);
155:                CompoundBorder border4 = new CompoundBorder(border1, border2);
156:                assertSame(border1, border4.getOutsideBorder());
157:                assertSame(border2, border4.getInsideBorder());
158:                CompoundBorder border5 = new CompoundBorder(border2, border3);
159:                assertSame(border2, border5.getOutsideBorder());
160:                assertSame(border3, border5.getInsideBorder());
161:                CompoundBorder border7 = new CompoundBorder(border2, null);
162:                assertSame(border2, border7.getOutsideBorder());
163:                assertNull(border7.getInsideBorder());
164:                CompoundBorder border8 = new CompoundBorder(null, border3);
165:                assertNull(border8.getOutsideBorder());
166:                assertSame(border3, border8.getInsideBorder());
167:            }
168:
169:            /*
170:             * Class under test for void CompoundBorder()
171:             */
172:            public void testCompoundBorder() {
173:                CompoundBorder border = new CompoundBorder();
174:                assertNull(border.getInsideBorder());
175:                assertNull(border.getOutsideBorder());
176:            }
177:
178:            public void testGetOutsideBorder() {
179:                LineBorder border1 = new LineBorder(Color.red, 33, false);
180:                LineBorder border2 = new LineBorder(Color.red, 33, true);
181:                EmptyBorder border3 = new EmptyBorder(1, 1, 1, 1);
182:                CompoundBorder border4 = new CompoundBorder(border1, border2);
183:                CompoundBorder border5 = new CompoundBorder(border2, border3);
184:                CompoundBorder border6 = new CompoundBorder();
185:                CompoundBorder border7 = new CompoundBorder(border2, null);
186:                CompoundBorder border8 = new CompoundBorder(null, border3);
187:                assertEquals("Borders coincide", border1, border4
188:                        .getOutsideBorder());
189:                assertEquals("Borders coincide", border2, border5
190:                        .getOutsideBorder());
191:                assertNull("Borders coincide", border6.getOutsideBorder());
192:                assertEquals("Borders coincide", border2, border7
193:                        .getOutsideBorder());
194:                assertNull("Borders coincide", border8.getOutsideBorder());
195:            }
196:
197:            public void testGetInsideBorder() {
198:                LineBorder border1 = new LineBorder(Color.red, 33, false);
199:                LineBorder border2 = new LineBorder(Color.red, 33, true);
200:                EmptyBorder border3 = new EmptyBorder(1, 1, 1, 1);
201:                CompoundBorder border4 = new CompoundBorder(border1, border2);
202:                CompoundBorder border5 = new CompoundBorder(border2, border3);
203:                CompoundBorder border6 = new CompoundBorder();
204:                CompoundBorder border7 = new CompoundBorder(border2, null);
205:                CompoundBorder border8 = new CompoundBorder(null, border3);
206:                assertEquals("Borders coincide", border2, border4
207:                        .getInsideBorder());
208:                assertEquals("Borders coincide", border3, border5
209:                        .getInsideBorder());
210:                assertNull("Borders coincide", border6.getInsideBorder());
211:                assertNull("Borders coincide", border7.getInsideBorder());
212:                assertEquals("Borders coincide", border3, border8
213:                        .getInsideBorder());
214:            }
215:
216:            public void testReadWriteObject() throws Exception {
217:                LineBorder border1 = new LineBorder(Color.red, 33, false);
218:                EmptyBorder border2 = new EmptyBorder(1, 1, 1, 1);
219:                CompoundBorder border3 = new CompoundBorder(border1, border2);
220:                CompoundBorder border4 = new CompoundBorder();
221:                CompoundBorder resurrectedBorder = (CompoundBorder) serializeObject(border3);
222:                assertNotNull(resurrectedBorder);
223:                assertEquals("Deserialized values coincides", resurrectedBorder
224:                        .getOutsideBorder().getClass(), border1.getClass());
225:                assertEquals("Deserialized values coincides", resurrectedBorder
226:                        .getInsideBorder().getClass(), border2.getClass());
227:                resurrectedBorder = (CompoundBorder) serializeObject(border4);
228:                assertNotNull(resurrectedBorder);
229:                assertNull("Deserialized values coincides", resurrectedBorder
230:                        .getOutsideBorder());
231:                assertNull("Deserialized values coincides", resurrectedBorder
232:                        .getInsideBorder());
233:            }
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.