Source Code Cross Referenced for EtchedBorderTest.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 03.12.2004
021:
022:         */package javax.swing.border;
023:
024:        import java.awt.Color;
025:        import java.awt.Insets;
026:        import javax.swing.JComponent;
027:        import javax.swing.JPanel;
028:        import javax.swing.SwingTestCase;
029:
030:        public class EtchedBorderTest extends SwingTestCase {
031:            public static void main(final String[] args) {
032:                junit.textui.TestRunner.run(EtchedBorderTest.class);
033:            }
034:
035:            /*
036:             * Class under test for void EtchedBorder()
037:             */
038:            public void testEtchedBorder() {
039:                int etchType = EtchedBorder.LOWERED;
040:                Color shadowColor = null;
041:                Color highlightedColor = null;
042:                EtchedBorder border = new EtchedBorder();
043:                assertEquals("Shadow color coinsides", shadowColor, border
044:                        .getShadowColor());
045:                assertEquals("Highlighted color coinsides", highlightedColor,
046:                        border.getHighlightColor());
047:                assertEquals("Etch type coinsides", etchType, border
048:                        .getEtchType());
049:            }
050:
051:            /*
052:             * Class under test for void EtchedBorder(int)
053:             */
054:            public void testEtchedBorderint() {
055:                int etchType = EtchedBorder.LOWERED;
056:                Color shadowColor = null;
057:                Color highlightedColor = null;
058:                EtchedBorder border = new EtchedBorder(etchType);
059:                assertEquals("Shadow color coinsides", shadowColor, border
060:                        .getShadowColor());
061:                assertEquals("Highlighted color coinsides", highlightedColor,
062:                        border.getHighlightColor());
063:                assertEquals("Etch type coinsides", etchType, border
064:                        .getEtchType());
065:                etchType = EtchedBorder.RAISED;
066:                border = new EtchedBorder(etchType);
067:                assertEquals("Shadow color coinsides", shadowColor, border
068:                        .getShadowColor());
069:                assertEquals("Highlighted color coinsides", highlightedColor,
070:                        border.getHighlightColor());
071:                assertEquals("Etch type coinsides", etchType, border
072:                        .getEtchType());
073:            }
074:
075:            /*
076:             * Class under test for void EtchedBorder(Color, Color)
077:             */
078:            public void testEtchedBorderColorColor() {
079:                int etchType = EtchedBorder.LOWERED;
080:                Color shadowColor = Color.YELLOW;
081:                Color highlightedColor = Color.RED;
082:                EtchedBorder border = new EtchedBorder(highlightedColor,
083:                        shadowColor);
084:                assertEquals("Shadow color coinsides", shadowColor, border
085:                        .getShadowColor());
086:                assertEquals("Highlighted color coinsides", highlightedColor,
087:                        border.getHighlightColor());
088:                assertEquals("Etch type coinsides", etchType, border
089:                        .getEtchType());
090:                shadowColor = Color.GREEN;
091:                highlightedColor = Color.WHITE;
092:                border = new EtchedBorder(highlightedColor, shadowColor);
093:                assertEquals("Shadow color coinsides", shadowColor, border
094:                        .getShadowColor());
095:                assertEquals("Highlighted color coinsides", highlightedColor,
096:                        border.getHighlightColor());
097:                assertEquals("Etch type coinsides", etchType, border
098:                        .getEtchType());
099:            }
100:
101:            /*
102:             * Class under test for void EtchedBorder(int, Color, Color)
103:             */
104:            public void testEtchedBorderintColorColor() {
105:                int etchType = EtchedBorder.LOWERED;
106:                Color shadowColor = Color.YELLOW;
107:                Color highlightedColor = Color.RED;
108:                EtchedBorder border = new EtchedBorder(etchType,
109:                        highlightedColor, shadowColor);
110:                assertEquals("Shadow color coinsides", shadowColor, border
111:                        .getShadowColor());
112:                assertEquals("Highlighted color coinsides", highlightedColor,
113:                        border.getHighlightColor());
114:                assertEquals("Etch type coinsides", etchType, border
115:                        .getEtchType());
116:                etchType = EtchedBorder.RAISED;
117:                shadowColor = Color.GREEN;
118:                highlightedColor = Color.WHITE;
119:                border = new EtchedBorder(etchType, highlightedColor,
120:                        shadowColor);
121:                assertEquals("Shadow color coinsides", shadowColor, border
122:                        .getShadowColor());
123:                assertEquals("Highlighted color coinsides", highlightedColor,
124:                        border.getHighlightColor());
125:                assertEquals("Etch type coinsides", etchType, border
126:                        .getEtchType());
127:            }
128:
129:            /*
130:             * Class under test for Insets getBorderInsets(Component, Insets)
131:             */
132:            public void testGetBorderInsetsComponentInsets() {
133:                int thickness1 = 2;
134:                int thickness2 = 22;
135:                int thickness3 = 33;
136:                EtchedBorder border = new EtchedBorder(Color.black, Color.white);
137:                Insets insets = new Insets(1, 1, 1, 1);
138:                JPanel panel = new JPanel();
139:                border.getBorderInsets(panel, insets);
140:                assertEquals("insets values coinside", thickness1, insets.top);
141:                assertEquals("insets values coinside", thickness1, insets.left);
142:                assertEquals("insets values coinside", thickness1, insets.right);
143:                assertEquals("insets values coinside", thickness1,
144:                        insets.bottom);
145:                panel.setBorder(new LineBorder(Color.black, thickness2));
146:                border.getBorderInsets(panel, insets);
147:                assertEquals("insets values coinside", thickness1, insets.top);
148:                assertEquals("insets values coinside", thickness1, insets.left);
149:                assertEquals("insets values coinside", thickness1, insets.right);
150:                assertEquals("insets values coinside", thickness1,
151:                        insets.bottom);
152:                insets = new Insets(thickness3, thickness3, thickness3,
153:                        thickness3);
154:                panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
155:                Insets newInsets = border.getBorderInsets(panel, insets);
156:                assertEquals("insets values coinside", thickness1,
157:                        newInsets.top);
158:                assertEquals("insets values coinside", thickness1,
159:                        newInsets.left);
160:                assertEquals("insets values coinside", thickness1,
161:                        newInsets.right);
162:                assertEquals("insets values coinside", thickness1,
163:                        newInsets.bottom);
164:                assertEquals("insets values coinside", thickness1, insets.top);
165:                assertEquals("insets values coinside", thickness1, insets.left);
166:                assertEquals("insets values coinside", thickness1, insets.right);
167:                assertEquals("insets values coinside", thickness1,
168:                        insets.bottom);
169:            }
170:
171:            /*
172:             * Class under test for Insets getBorderInsets(Component)
173:             */
174:            public void testGetBorderInsetsComponent() {
175:                int thickness1 = 2;
176:                int thickness2 = 22;
177:                int thickness3 = 33;
178:                EtchedBorder border = new EtchedBorder(Color.black, Color.white);
179:                Insets insets = new Insets(1, 1, 1, 1);
180:                JPanel panel = new JPanel();
181:                insets = border.getBorderInsets(null);
182:                assertEquals("insets values coinside", thickness1, insets.top);
183:                assertEquals("insets values coinside", thickness1, insets.left);
184:                assertEquals("insets values coinside", thickness1, insets.right);
185:                assertEquals("insets values coinside", thickness1,
186:                        insets.bottom);
187:                panel.setBorder(new LineBorder(Color.black, thickness2));
188:                insets = border.getBorderInsets(panel);
189:                assertEquals("insets values coinside", thickness1, insets.top);
190:                assertEquals("insets values coinside", thickness1, insets.left);
191:                assertEquals("insets values coinside", thickness1, insets.right);
192:                assertEquals("insets values coinside", thickness1,
193:                        insets.bottom);
194:                insets = new Insets(thickness3, thickness3, thickness3,
195:                        thickness3);
196:                panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
197:                insets = border.getBorderInsets(panel);
198:                assertEquals("insets values coinside", thickness1, insets.top);
199:                assertEquals("insets values coinside", thickness1, insets.left);
200:                assertEquals("insets values coinside", thickness1, insets.right);
201:                assertEquals("insets values coinside", thickness1,
202:                        insets.bottom);
203:            }
204:
205:            public void testPaintBorder() {
206:                //        JPanel panel1 = new JPanel();
207:                //        JPanel panel2 = new JPanel();
208:                //        JPanel panel3 = new JPanel();
209:                //
210:                //        EtchedBorder border1 = new EtchedBorder(EtchedBorder.LOWERED, Color.red, Color.yellow);
211:                //        EtchedBorder border2 = new EtchedBorder(EtchedBorder.RAISED, Color.red, Color.yellow);
212:                //        panel2.setBorder(border1);
213:                //        panel3.setBorder(border2);
214:                //        panel2.setPreferredSize(new Dimension(200, 150));
215:                //        panel3.setPreferredSize(new Dimension(200, 150));
216:                //
217:                //        panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));
218:                //        panel1.add(panel2);
219:                //        panel1.add(panel3);
220:                //
221:                //        JFrame frame = new JFrame();
222:                //        frame.getContentPane().add(panel1);
223:                //        frame.pack();
224:                //        frame.show();
225:                //        while(!frame.isActive());
226:                //        while(frame.isActive());
227:            }
228:
229:            public void testIsBorderOpaque() {
230:                Color shadowColor = Color.GREEN;
231:                Color highlightedColor = Color.RED;
232:                EtchedBorder border = new EtchedBorder(highlightedColor,
233:                        shadowColor);
234:                assertTrue("EtchedBorder is opaque", border.isBorderOpaque());
235:                border = new EtchedBorder();
236:                assertTrue("EtchedBorder is opaque", border.isBorderOpaque());
237:            }
238:
239:            /*
240:             * Class under test for Color getShadowColor(Component)
241:             */
242:            public void testGetShadowColorComponent() {
243:                JComponent c1 = new JPanel();
244:                JComponent c2 = new JPanel();
245:                c1.setBackground(new Color(110, 110, 110));
246:                c1.setForeground(new Color(210, 210, 210));
247:                c2.setBackground(new Color(10, 10, 10));
248:                c2.setForeground(new Color(110, 110, 110));
249:                Color shadowColor = Color.GREEN;
250:                Color highlightedColor = Color.RED;
251:                EtchedBorder border = new EtchedBorder(highlightedColor,
252:                        shadowColor);
253:                assertEquals("Shadow color coinsides", shadowColor, border
254:                        .getShadowColor(c1));
255:                assertEquals("Shadow color coinsides", shadowColor, border
256:                        .getShadowColor(c2));
257:                border = new EtchedBorder();
258:                assertEquals("Shadow color coinsides", new Color(77, 77, 77),
259:                        border.getShadowColor(c1));
260:                assertEquals("Shadow color coinsides", new Color(7, 7, 7),
261:                        border.getShadowColor(c2));
262:            }
263:
264:            /*
265:             * Class under test for Color getHighlightColor(Component)
266:             */
267:            public void testGetHighlightColorComponent() {
268:                JComponent c1 = new JPanel();
269:                JComponent c2 = new JPanel();
270:                c1.setBackground(new Color(110, 110, 110));
271:                c1.setForeground(new Color(210, 210, 210));
272:                c2.setBackground(new Color(10, 10, 10));
273:                c2.setForeground(new Color(110, 110, 110));
274:                Color shadowColor = Color.GREEN;
275:                Color highlightedColor = Color.RED;
276:                EtchedBorder border = new EtchedBorder(highlightedColor,
277:                        shadowColor);
278:                assertEquals("Highlight color coinsides", highlightedColor,
279:                        border.getHighlightColor(c1));
280:                assertEquals("Highlight color coinsides", highlightedColor,
281:                        border.getHighlightColor(c2));
282:                border = new EtchedBorder();
283:                assertEquals("Highlight color coinsides", new Color(157, 157,
284:                        157), border.getHighlightColor(c1));
285:                assertEquals("Highlight color coinsides",
286:                        new Color(14, 14, 14), border.getHighlightColor(c2));
287:            }
288:
289:            /*
290:             * Class under test for Color getShadowColor()
291:             */
292:            public void testGetShadowColor() {
293:                Color shadowColor = Color.YELLOW;
294:                Color highlightedColor = Color.RED;
295:                EtchedBorder border = new EtchedBorder(highlightedColor,
296:                        shadowColor);
297:                assertEquals("Shadow color coinsides", shadowColor, border
298:                        .getShadowColor());
299:                shadowColor = Color.GREEN;
300:                highlightedColor = Color.WHITE;
301:                border = new EtchedBorder(highlightedColor, shadowColor);
302:                assertEquals("Shadow color coinsides", shadowColor, border
303:                        .getShadowColor());
304:            }
305:
306:            /*
307:             * Class under test for Color getHighlightColor()
308:             */
309:            public void testGetHighlightColor() {
310:                Color shadowColor = Color.YELLOW;
311:                Color highlightedColor = Color.RED;
312:                EtchedBorder border = new EtchedBorder(highlightedColor,
313:                        shadowColor);
314:                assertEquals("Highlighted color coinsides", highlightedColor,
315:                        border.getHighlightColor());
316:                shadowColor = Color.GREEN;
317:                highlightedColor = Color.WHITE;
318:                border = new EtchedBorder(highlightedColor, shadowColor);
319:                assertEquals("Highlighted color coinsides", highlightedColor,
320:                        border.getHighlightColor());
321:            }
322:
323:            public void testGetEtchType() {
324:                int etchType = EtchedBorder.LOWERED;
325:                EtchedBorder border = new EtchedBorder(etchType);
326:                assertEquals("Etch type coinsides", etchType, border
327:                        .getEtchType());
328:                etchType = EtchedBorder.RAISED;
329:                border = new EtchedBorder(etchType);
330:                assertEquals("Etch type coinsides", etchType, border
331:                        .getEtchType());
332:            }
333:
334:            public void testReadWriteObject() throws Exception {
335:                Color shadowColor1 = Color.RED;
336:                Color shadowColor2 = Color.BLUE;
337:                Color highlightedColor1 = Color.YELLOW;
338:                Color highlightedColor2 = Color.GREEN;
339:                int etchType1 = EtchedBorder.LOWERED;
340:                int etchType2 = EtchedBorder.RAISED;
341:                EtchedBorder border1 = new EtchedBorder(etchType1,
342:                        highlightedColor1, shadowColor1);
343:                EtchedBorder border2 = new EtchedBorder(etchType2,
344:                        highlightedColor2, shadowColor2);
345:                EtchedBorder resurrectedBorder = (EtchedBorder) serializeObject(border1);
346:                assertNotNull(resurrectedBorder);
347:                assertEquals("Deserialized values coinsides", resurrectedBorder
348:                        .getEtchType(), border1.getEtchType());
349:                assertEquals("Deserialized values coinsides", resurrectedBorder
350:                        .getShadowColor(), border1.getShadowColor());
351:                assertEquals("Deserialized values coinsides", resurrectedBorder
352:                        .getHighlightColor(), border1.getHighlightColor());
353:                resurrectedBorder = (EtchedBorder) serializeObject(border2);
354:                assertNotNull(resurrectedBorder);
355:                assertEquals("Deserialized values coinsides", resurrectedBorder
356:                        .getEtchType(), border2.getEtchType());
357:                assertEquals("Deserialized values coinsides", resurrectedBorder
358:                        .getShadowColor(), border2.getShadowColor());
359:                assertEquals("Deserialized values coinsides", resurrectedBorder
360:                        .getHighlightColor(), border2.getHighlightColor());
361:            }
362:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.