Source Code Cross Referenced for SoftBevelBorderTest.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; //import java.awt.Dimension;
025:        import java.awt.Insets; //import javax.swing.BoxLayout;
026:        //import javax.swing.JFrame;
027:        import javax.swing.JPanel;
028:        import javax.swing.SwingTestCase;
029:
030:        public class SoftBevelBorderTest extends SwingTestCase {
031:            public static void main(final String[] args) {
032:                junit.textui.TestRunner.run(SoftBevelBorderTest.class);
033:            }
034:
035:            /*
036:             * Class under test for void SoftBevelBorder(int, Color, Color, Color, Color)
037:             */
038:            public void testSoftBevelBorderintColorColorColorColor() {
039:                int bevelType = BevelBorder.LOWERED;
040:                Color highlightOuterColor = Color.RED;
041:                Color highlightInnerColor = Color.YELLOW;
042:                Color shadowOuterColor = Color.GREEN;
043:                Color shadowInnerColor = Color.BLACK;
044:                SoftBevelBorder border = new SoftBevelBorder(bevelType,
045:                        highlightOuterColor, highlightInnerColor,
046:                        shadowOuterColor, shadowInnerColor);
047:                assertEquals("highlightOuterColor coinsides",
048:                        highlightOuterColor, border.getHighlightOuterColor());
049:                assertEquals("highlightInnerColor coinsides",
050:                        highlightInnerColor, border.getHighlightInnerColor());
051:                assertEquals("shadowOuterColor coinsides", shadowOuterColor,
052:                        border.getShadowOuterColor());
053:                assertEquals("shadowInnerColor coinsides", shadowInnerColor,
054:                        border.getShadowInnerColor());
055:                assertEquals("Bevel type coinsides", bevelType, border
056:                        .getBevelType());
057:                bevelType = BevelBorder.RAISED;
058:                highlightOuterColor = Color.YELLOW;
059:                highlightInnerColor = Color.RED;
060:                shadowOuterColor = Color.WHITE;
061:                shadowInnerColor = Color.BLUE;
062:                border = new SoftBevelBorder(bevelType, highlightOuterColor,
063:                        highlightInnerColor, shadowOuterColor, shadowInnerColor);
064:                assertEquals("highlightOuterColor coinsides",
065:                        highlightOuterColor, border.getHighlightOuterColor());
066:                assertEquals("highlightInnerColor coinsides",
067:                        highlightInnerColor, border.getHighlightInnerColor());
068:                assertEquals("shadowOuterColor coinsides", shadowOuterColor,
069:                        border.getShadowOuterColor());
070:                assertEquals("shadowInnerColor coinsides", shadowInnerColor,
071:                        border.getShadowInnerColor());
072:                assertEquals("Bevel type coinsides", bevelType, border
073:                        .getBevelType());
074:            }
075:
076:            /*
077:             * Class under test for void SoftBevelBorder(int, Color, Color)
078:             */
079:            public void testSoftBevelBorderintColorColor() {
080:                int bevelType = BevelBorder.LOWERED;
081:                Color highlightColor = Color.RED;
082:                Color shadowColor = Color.GREEN;
083:                SoftBevelBorder border = new SoftBevelBorder(bevelType,
084:                        highlightColor, shadowColor);
085:                assertEquals("highlightOuterColor coinsides", highlightColor,
086:                        border.getHighlightOuterColor());
087:                assertEquals("highlightInnerColor coinsides", highlightColor,
088:                        border.getHighlightInnerColor());
089:                assertEquals("shadowOuterColor coinsides", shadowColor, border
090:                        .getShadowOuterColor());
091:                assertEquals("shadowInnerColor coinsides", shadowColor, border
092:                        .getShadowInnerColor());
093:                assertEquals("Bevel type coinsides", bevelType, border
094:                        .getBevelType());
095:                bevelType = BevelBorder.RAISED;
096:                highlightColor = Color.YELLOW;
097:                shadowColor = Color.WHITE;
098:                border = new SoftBevelBorder(bevelType, highlightColor,
099:                        shadowColor);
100:                assertEquals("highlightOuterColor coinsides", highlightColor,
101:                        border.getHighlightOuterColor());
102:                assertEquals("highlightInnerColor coinsides", highlightColor,
103:                        border.getHighlightInnerColor());
104:                assertEquals("shadowOuterColor coinsides", shadowColor, border
105:                        .getShadowOuterColor());
106:                assertEquals("shadowInnerColor coinsides", shadowColor, border
107:                        .getShadowInnerColor());
108:                assertEquals("Bevel type coinsides", bevelType, border
109:                        .getBevelType());
110:            }
111:
112:            /*
113:             * Class under test for void SoftBevelBorder(int)
114:             */
115:            public void testSoftBevelBorderint() {
116:                int bevelType = BevelBorder.LOWERED;
117:                Color highlightColor = null;
118:                Color shadowColor = null;
119:                SoftBevelBorder border = new SoftBevelBorder(bevelType);
120:                assertEquals("highlightOuterColor coinsides", highlightColor,
121:                        border.getHighlightOuterColor());
122:                assertEquals("highlightInnerColor coinsides", highlightColor,
123:                        border.getHighlightInnerColor());
124:                assertEquals("shadowOuterColor coinsides", shadowColor, border
125:                        .getShadowOuterColor());
126:                assertEquals("shadowInnerColor coinsides", shadowColor, border
127:                        .getShadowInnerColor());
128:                assertEquals("Bevel type coinsides", bevelType, border
129:                        .getBevelType());
130:                bevelType = BevelBorder.RAISED;
131:                border = new SoftBevelBorder(bevelType);
132:                assertEquals("highlightOuterColor coinsides", highlightColor,
133:                        border.getHighlightOuterColor());
134:                assertEquals("highlightInnerColor coinsides", highlightColor,
135:                        border.getHighlightInnerColor());
136:                assertEquals("shadowOuterColor coinsides", shadowColor, border
137:                        .getShadowOuterColor());
138:                assertEquals("shadowInnerColor coinsides", shadowColor, border
139:                        .getShadowInnerColor());
140:                assertEquals("Bevel type coinsides", bevelType, border
141:                        .getBevelType());
142:            }
143:
144:            /*
145:             * Class under test for Insets getBorderInsets(Component, Insets)
146:             */
147:            public void testGetBorderInsetsComponentInsets() {
148:                int thickness1 = 3;
149:                int thickness2 = 22;
150:                int thickness3 = 33;
151:                SoftBevelBorder border = new SoftBevelBorder(
152:                        BevelBorder.RAISED, Color.black, Color.white);
153:                Insets insets = new Insets(10, 10, 10, 10);
154:                JPanel panel = new JPanel();
155:                border.getBorderInsets(panel, insets);
156:                assertEquals("insets values coinside", thickness1, insets.top);
157:                assertEquals("insets values coinside", thickness1, insets.left);
158:                assertEquals("insets values coinside", thickness1, insets.right);
159:                assertEquals("insets values coinside", thickness1,
160:                        insets.bottom);
161:                panel.setBorder(new LineBorder(Color.black, thickness2));
162:                border.getBorderInsets(panel, insets);
163:                assertEquals("insets values coinside", thickness1, insets.top);
164:                assertEquals("insets values coinside", thickness1, insets.left);
165:                assertEquals("insets values coinside", thickness1, insets.right);
166:                assertEquals("insets values coinside", thickness1,
167:                        insets.bottom);
168:                insets = new Insets(thickness3, thickness3, thickness3,
169:                        thickness3);
170:                panel.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
171:                Insets newInsets = border.getBorderInsets(panel, insets);
172:                assertEquals("insets values coinside", thickness1,
173:                        newInsets.top);
174:                assertEquals("insets values coinside", thickness1,
175:                        newInsets.left);
176:                assertEquals("insets values coinside", thickness1,
177:                        newInsets.right);
178:                assertEquals("insets values coinside", thickness1,
179:                        newInsets.bottom);
180:                assertEquals("insets values coinside", thickness1, insets.top);
181:                assertEquals("insets values coinside", thickness1, insets.left);
182:                assertEquals("insets values coinside", thickness1, insets.right);
183:                assertEquals("insets values coinside", thickness1,
184:                        insets.bottom);
185:            }
186:
187:            /*
188:             * Class under test for Insets getBorderInsets(Component)
189:             */
190:            public void testGetBorderInsetsComponent() {
191:                int thickness1 = 3;
192:                int thickness2 = 22;
193:                int thickness3 = 33;
194:                SoftBevelBorder border = new SoftBevelBorder(
195:                        BevelBorder.RAISED, Color.black, Color.white);
196:                Insets insets = new Insets(10, 10, 10, 10);
197:                JPanel panel = new JPanel();
198:                insets = border.getBorderInsets(null);
199:                assertEquals("insets values coinside", thickness1, insets.top);
200:                assertEquals("insets values coinside", thickness1, insets.left);
201:                assertEquals("insets values coinside", thickness1, insets.right);
202:                assertEquals("insets values coinside", thickness1,
203:                        insets.bottom);
204:                panel.setBorder(new LineBorder(Color.black, thickness2));
205:                insets = border.getBorderInsets(panel);
206:                assertEquals("insets values coinside", thickness1, insets.top);
207:                assertEquals("insets values coinside", thickness1, insets.left);
208:                assertEquals("insets values coinside", thickness1, insets.right);
209:                assertEquals("insets values coinside", thickness1,
210:                        insets.bottom);
211:                insets = new Insets(thickness3, thickness3, thickness3,
212:                        thickness3);
213:                panel.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
214:                insets = border.getBorderInsets(panel);
215:                assertEquals("insets values coinside", thickness1, insets.top);
216:                assertEquals("insets values coinside", thickness1, insets.left);
217:                assertEquals("insets values coinside", thickness1, insets.right);
218:                assertEquals("insets values coinside", thickness1,
219:                        insets.bottom);
220:            }
221:
222:            public void testPaintBorder() {
223:                //      JPanel panel1 = new JPanel();
224:                //      JPanel panel2 = new JPanel();
225:                //      JPanel panel3 = new JPanel();
226:                //
227:                //      Color shadowInnerColor = Color.GREEN;
228:                //      Color shadowOuterColor = Color.BLACK;
229:                //      Color highlightedInnerColor = Color.RED;
230:                //      Color highlightedOuterColor = Color.BLUE;
231:                //
232:                //      SoftBevelBorder border1 = new SoftBevelBorder(EtchedBorder.LOWERED, highlightedOuterColor, highlightedInnerColor,
233:                //                                                                  shadowOuterColor, shadowInnerColor);
234:                //      SoftBevelBorder border2 = new SoftBevelBorder(EtchedBorder.RAISED, highlightedOuterColor, highlightedInnerColor,
235:                //                                                                  shadowOuterColor, shadowInnerColor);
236:                //      panel2.setBorder(border1);
237:                //      panel3.setBorder(border2);
238:                //      panel2.setPreferredSize(new Dimension(200, 150));
239:                //      panel3.setPreferredSize(new Dimension(200, 150));
240:                //
241:                //      panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));
242:                //      panel1.add(panel2);
243:                //      panel1.add(panel3);
244:                //
245:                //      JFrame frame = new JFrame();
246:                //      frame.getContentPane().add(panel1);
247:                //      frame.pack();
248:                //      frame.show();
249:                //      while(!frame.isActive());
250:                //      while(frame.isActive());
251:            }
252:
253:            public void testIsBorderOpaque() {
254:                Color shadowColor = Color.GREEN;
255:                Color highlightedColor = Color.RED;
256:                SoftBevelBorder border = new SoftBevelBorder(
257:                        BevelBorder.LOWERED, highlightedColor, shadowColor);
258:                assertFalse("SoftBevelBorder is not opaque", border
259:                        .isBorderOpaque());
260:                border = new SoftBevelBorder(BevelBorder.RAISED);
261:                assertFalse("SoftBevelBorder is not opaque", border
262:                        .isBorderOpaque());
263:            }
264:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.