Source Code Cross Referenced for JScrollPaneTest.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » 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 
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 Anton Avtamonov, Sergey Burlak
019:         * @version $Revision$
020:         */package javax.swing;
021:
022:        import java.awt.Adjustable;
023:        import java.awt.Component;
024:        import java.awt.ComponentOrientation;
025:        import java.awt.Container;
026:        import java.awt.Dimension;
027:        import java.awt.LayoutManager;
028:        import java.awt.Rectangle;
029:        import javax.swing.border.Border;
030:        import javax.swing.plaf.ScrollPaneUI;
031:        import javax.swing.plaf.basic.BasicScrollPaneUI;
032:
033:        public class JScrollPaneTest extends SwingTestCase {
034:            private JScrollPane pane;
035:
036:            public JScrollPaneTest(final String name) {
037:                super (name);
038:            }
039:
040:            @Override
041:            protected void setUp() throws Exception {
042:                pane = new JScrollPane();
043:                propertyChangeController = new PropertyChangeController();
044:                pane.addPropertyChangeListener(propertyChangeController);
045:            }
046:
047:            @Override
048:            protected void tearDown() throws Exception {
049:                pane = null;
050:            }
051:
052:            public void testJScrollPane() throws Exception {
053:                assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
054:                        pane.verticalScrollBarPolicy);
055:                assertEquals(
056:                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED,
057:                        pane.horizontalScrollBarPolicy);
058:                assertNotNull(pane.viewport);
059:                assertNull(pane.viewport.getView());
060:                assertTrue(pane.verticalScrollBar instanceof  JScrollPane.ScrollBar);
061:                assertEquals(Adjustable.VERTICAL, pane.verticalScrollBar
062:                        .getOrientation());
063:                assertTrue(pane.horizontalScrollBar instanceof  JScrollPane.ScrollBar);
064:                assertEquals(Adjustable.HORIZONTAL, pane.horizontalScrollBar
065:                        .getOrientation());
066:                assertNull(pane.rowHeader);
067:                assertNull(pane.columnHeader);
068:                assertNull(pane.lowerLeft);
069:                assertNull(pane.lowerRight);
070:                assertNull(pane.upperLeft);
071:                assertNull(pane.upperRight);
072:                assertEquals(3, pane.getComponentCount());
073:                assertEquals(pane.viewport, pane.getComponent(0));
074:                assertEquals(pane.verticalScrollBar, pane.getComponent(1));
075:                assertEquals(pane.horizontalScrollBar, pane.getComponent(2));
076:                Component view = new JButton();
077:                pane = new JScrollPane(view,
078:                        ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
079:                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
080:                assertEquals(view, pane.viewport.getView());
081:                assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
082:                        pane.verticalScrollBarPolicy);
083:                assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS,
084:                        pane.horizontalScrollBarPolicy);
085:                view = new JButton();
086:                pane = new JScrollPane(view);
087:                assertEquals(view, pane.viewport.getView());
088:                assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
089:                        pane.verticalScrollBarPolicy);
090:                assertEquals(
091:                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED,
092:                        pane.horizontalScrollBarPolicy);
093:                pane = new JScrollPane(
094:                        ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
095:                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
096:                assertNull(pane.viewport.getView());
097:                assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
098:                        pane.verticalScrollBarPolicy);
099:                assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
100:                        pane.horizontalScrollBarPolicy);
101:                testExceptionalCase(new IllegalArgumentCase() {
102:                    @Override
103:                    public void exceptionalAction() throws Exception {
104:                        new JScrollPane(
105:                                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS,
106:                                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
107:                    }
108:                });
109:                testExceptionalCase(new IllegalArgumentCase() {
110:                    @Override
111:                    public void exceptionalAction() throws Exception {
112:                        new JScrollPane(
113:                                ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
114:                                ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
115:                    }
116:                });
117:            }
118:
119:            public void testGetSetUpdateUI() throws Exception {
120:                assertNotNull(pane.getUI());
121:                ScrollPaneUI ui = new BasicScrollPaneUI();
122:                pane.setUI(ui);
123:                assertEquals(ui, pane.getUI());
124:                pane.updateUI();
125:                assertNotSame(ui, pane.getUI());
126:            }
127:
128:            public void testGetUICalssID() throws Exception {
129:                assertEquals("ScrollPaneUI", pane.getUIClassID());
130:            }
131:
132:            public void testSetLayout() throws Exception {
133:                assertTrue(pane.getLayout() instanceof  ScrollPaneLayout);
134:                TestLayout layout = new TestLayout();
135:                pane.setLayout(layout);
136:                assertEquals(layout, pane.getLayout());
137:                assertEquals(pane, layout.getSyncScrollPane());
138:                pane.setLayout(null);
139:                testExceptionalCase(new ExceptionalCase() {
140:                    @Override
141:                    public void exceptionalAction() throws Exception {
142:                        pane.setLayout(new LayoutManager() {
143:                            public void addLayoutComponent(final String name,
144:                                    final Component comp) {
145:                            }
146:
147:                            public void layoutContainer(final Container parent) {
148:                            }
149:
150:                            public Dimension minimumLayoutSize(
151:                                    final Container parent) {
152:                                return null;
153:                            }
154:
155:                            public Dimension preferredLayoutSize(
156:                                    final Container parent) {
157:                                return null;
158:                            }
159:
160:                            public void removeLayoutComponent(
161:                                    final Component comp) {
162:                            }
163:                        });
164:                    }
165:
166:                    @Override
167:                    public Class<ClassCastException> expectedExceptionClass() {
168:                        return ClassCastException.class;
169:                    }
170:                });
171:            }
172:
173:            public void testIsValidRoot() throws Exception {
174:                assertTrue(pane.isValidateRoot());
175:            }
176:
177:            public void testGetSetVerticalScrollBarPolicy() throws Exception {
178:                assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
179:                        pane.getVerticalScrollBarPolicy());
180:                pane
181:                        .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
182:                assertTrue(propertyChangeController
183:                        .isChanged("verticalScrollBarPolicy"));
184:                assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
185:                        pane.getVerticalScrollBarPolicy());
186:                pane
187:                        .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
188:                assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, pane
189:                        .getVerticalScrollBarPolicy());
190:                testExceptionalCase(new IllegalArgumentCase() {
191:                    @Override
192:                    public void exceptionalAction() throws Exception {
193:                        pane
194:                                .setVerticalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
195:                    }
196:                });
197:            }
198:
199:            public void testGetSetHorizontalScrollBarPolicy() throws Exception {
200:                assertEquals(
201:                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED,
202:                        pane.getHorizontalScrollBarPolicy());
203:                pane
204:                        .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
205:                assertTrue(propertyChangeController
206:                        .isChanged("horizontalScrollBarPolicy"));
207:                assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS,
208:                        pane.getHorizontalScrollBarPolicy());
209:                pane
210:                        .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
211:                assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
212:                        pane.getHorizontalScrollBarPolicy());
213:                testExceptionalCase(new IllegalArgumentCase() {
214:                    @Override
215:                    public void exceptionalAction() throws Exception {
216:                        pane
217:                                .setHorizontalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
218:                    }
219:                });
220:            }
221:
222:            public void testGetSetViewportBorder() throws Exception {
223:                assertNull(pane.getViewportBorder());
224:                Border border = BorderFactory.createEmptyBorder();
225:                pane.setViewportBorder(border);
226:                assertEquals(border, pane.getViewportBorder());
227:                assertTrue(propertyChangeController.isChanged("viewportBorder"));
228:            }
229:
230:            public void testGetViewportBorderBounds() throws Exception {
231:                pane.setBorder(BorderFactory.createEmptyBorder(5, 10, 15, 20));
232:                pane.setBounds(200, 200, 40, 60);
233:                assertEquals(new Rectangle(10, 5, 40 - 10 - 20, 60 - 5 - 15),
234:                        pane.getViewportBorderBounds());
235:                pane.setColumnHeader(new JViewport());
236:                pane.getColumnHeader().setBounds(10, 20, 20, 50);
237:                assertEquals(new Rectangle(10, 5 + 50, 40 - 10 - 20,
238:                        60 - 5 - 15 - 50), pane.getViewportBorderBounds());
239:                pane.setRowHeader(new JViewport());
240:                pane.getRowHeader().setBounds(10, 20, 20, 30);
241:                assertEquals(new Rectangle(10 + 20, 5 + 50, 40 - 10 - 20 - 20,
242:                        60 - 5 - 15 - 50), pane.getViewportBorderBounds());
243:                pane.getVerticalScrollBar().setBounds(20, 10, 30, 10);
244:                assertEquals(new Rectangle(10 + 20, 5 + 50, 40 - 10 - 20 - 20
245:                        - 30, 60 - 5 - 15 - 50), pane.getViewportBorderBounds());
246:                pane.getHorizontalScrollBar().setBounds(20, 10, 30, 50);
247:                assertEquals(new Rectangle(10 + 20, 5 + 50, 40 - 10 - 20 - 20
248:                        - 30, 60 - 5 - 15 - 50 - 50), pane
249:                        .getViewportBorderBounds());
250:            }
251:
252:            public void testCreateHorizontalScrollBar() throws Exception {
253:                JScrollBar scrollBar = pane.createHorizontalScrollBar();
254:                assertTrue(scrollBar instanceof  JScrollPane.ScrollBar);
255:                assertEquals(Adjustable.HORIZONTAL, scrollBar.getOrientation());
256:            }
257:
258:            public void testCreateVerticalScrollBar() throws Exception {
259:                JScrollBar scrollBar = pane.createVerticalScrollBar();
260:                assertTrue(scrollBar instanceof  JScrollPane.ScrollBar);
261:                assertEquals(Adjustable.VERTICAL, scrollBar.getOrientation());
262:            }
263:
264:            public void testGetSetHorizontalScrollBar() throws Exception {
265:                assertTrue(pane.getHorizontalScrollBar() instanceof  JScrollPane.ScrollBar);
266:                JScrollBar sb = new JScrollBar(Adjustable.VERTICAL);
267:                pane.setHorizontalScrollBar(sb);
268:                assertEquals(sb, pane.getHorizontalScrollBar());
269:                assertTrue(propertyChangeController
270:                        .isChanged("horizontalScrollBar"));
271:                assertEquals(Adjustable.VERTICAL, sb.getOrientation());
272:            }
273:
274:            public void testGetSetVerticalScrollBar() throws Exception {
275:                assertTrue(pane.getVerticalScrollBar() instanceof  JScrollPane.ScrollBar);
276:                JScrollBar sb = new JScrollBar(Adjustable.HORIZONTAL);
277:                pane.setVerticalScrollBar(sb);
278:                assertEquals(sb, pane.getVerticalScrollBar());
279:                assertTrue(propertyChangeController
280:                        .isChanged("verticalScrollBar"));
281:                assertEquals(Adjustable.HORIZONTAL, sb.getOrientation());
282:            }
283:
284:            public void testCreateViewport() throws Exception {
285:                assertNull(pane.createViewport().getView());
286:            }
287:
288:            public void testGetSetViewport() throws Exception {
289:                assertNotNull(pane.getViewport());
290:                JViewport viewport = new JViewport();
291:                pane.setViewport(viewport);
292:                assertEquals(viewport, pane.getViewport());
293:                assertEquals(3, pane.getComponentCount());
294:                assertEquals(viewport, pane.getComponent(2));
295:                JViewport newViewport = new JViewport();
296:                pane.setViewport(newViewport);
297:                assertEquals(newViewport, pane.getViewport());
298:                assertEquals(3, pane.getComponentCount());
299:                assertEquals(newViewport, pane.getComponent(2));
300:                assertTrue(propertyChangeController.isChanged("viewport"));
301:                pane.setViewport(null);
302:                assertNull(pane.getViewport());
303:                assertEquals(2, pane.getComponentCount());
304:                assertTrue(propertyChangeController.isChanged("viewport"));
305:                propertyChangeController.reset();
306:                pane.setViewport(null);
307:                assertNull(pane.getViewport());
308:                assertEquals(2, pane.getComponentCount());
309:                assertTrue(propertyChangeController.isChanged("viewport"));
310:                propertyChangeController.reset();
311:                pane.setViewport(newViewport);
312:                assertEquals(3, pane.getComponentCount());
313:                assertTrue(propertyChangeController.isChanged("viewport"));
314:                pane.remove(newViewport);
315:                propertyChangeController.reset();
316:                pane.setViewport(newViewport);
317:                assertEquals(3, pane.getComponentCount());
318:                assertFalse(propertyChangeController.isChanged("viewport"));
319:            }
320:
321:            public void testSetViewportView() throws Exception {
322:                assertNull(pane.getViewport().getView());
323:                Component c = new JButton();
324:                pane.setViewportView(c);
325:                assertEquals(c, pane.getViewport().getView());
326:                pane.setViewport(null);
327:                pane.setViewportView(c);
328:                assertEquals(c, pane.getViewport().getView());
329:                assertTrue(propertyChangeController.isChanged("viewport"));
330:            }
331:
332:            public void testGetSetRowHeader() throws Exception {
333:                assertNull(pane.getRowHeader());
334:                JViewport rowHeader = new JViewport();
335:                pane.setRowHeader(rowHeader);
336:                assertEquals(rowHeader, pane.getRowHeader());
337:                assertTrue(propertyChangeController.isChanged("rowHeader"));
338:                assertEquals(4, pane.getComponentCount());
339:                assertEquals(rowHeader, pane.getComponent(3));
340:                JViewport newRowHeader = new JViewport();
341:                pane.setRowHeader(newRowHeader);
342:                assertEquals(newRowHeader, pane.getRowHeader());
343:                assertEquals(4, pane.getComponentCount());
344:                assertEquals(newRowHeader, pane.getComponent(3));
345:                pane.setRowHeader(null);
346:                assertNull(pane.getRowHeader());
347:                assertEquals(3, pane.getComponentCount());
348:            }
349:
350:            public void testSetRowHeaderView() throws Exception {
351:                assertNull(pane.getRowHeader());
352:                Component c = new JButton();
353:                pane.setRowHeaderView(c);
354:                assertEquals(c, pane.getRowHeader().getView());
355:                assertTrue(propertyChangeController.isChanged("rowHeader"));
356:            }
357:
358:            public void testGetSetColumnHeader() throws Exception {
359:                assertNull(pane.getColumnHeader());
360:                JViewport columnHeader = new JViewport();
361:                pane.setColumnHeader(columnHeader);
362:                assertEquals(columnHeader, pane.getColumnHeader());
363:                assertTrue(propertyChangeController.isChanged("columnHeader"));
364:                assertEquals(4, pane.getComponentCount());
365:                assertEquals(columnHeader, pane.getComponent(3));
366:                JViewport newColumnHeader = new JViewport();
367:                pane.setColumnHeader(newColumnHeader);
368:                assertEquals(newColumnHeader, pane.getColumnHeader());
369:                assertEquals(4, pane.getComponentCount());
370:                assertEquals(newColumnHeader, pane.getComponent(3));
371:                pane.setColumnHeader(null);
372:                assertNull(pane.getColumnHeader());
373:                assertEquals(3, pane.getComponentCount());
374:            }
375:
376:            public void testSetColumnHeaderView() throws Exception {
377:                assertNull(pane.getColumnHeader());
378:                Component c = new JButton();
379:                pane.setColumnHeaderView(c);
380:                assertEquals(c, pane.getColumnHeader().getView());
381:                assertTrue(propertyChangeController.isChanged("columnHeader"));
382:            }
383:
384:            public void testGetSetCorner() throws Exception {
385:                assertNull(pane
386:                        .getCorner(ScrollPaneConstants.LOWER_LEFT_CORNER));
387:                assertNull(pane
388:                        .getCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER));
389:                assertNull(pane
390:                        .getCorner(ScrollPaneConstants.UPPER_LEFT_CORNER));
391:                assertNull(pane
392:                        .getCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER));
393:                assertNull(pane
394:                        .getCorner(ScrollPaneConstants.LOWER_LEADING_CORNER));
395:                assertNull(pane
396:                        .getCorner(ScrollPaneConstants.LOWER_TRAILING_CORNER));
397:                assertNull(pane
398:                        .getCorner(ScrollPaneConstants.UPPER_LEADING_CORNER));
399:                assertNull(pane
400:                        .getCorner(ScrollPaneConstants.UPPER_TRAILING_CORNER));
401:                assertEquals(3, pane.getComponentCount());
402:                Component lowerLeft = new JButton();
403:                Component lowerRight = new JButton();
404:                Component upperLeft = new JButton();
405:                Component upperRight = new JButton();
406:                Component lowerLeading = new JButton();
407:                Component lowerTrailing = new JButton();
408:                Component upperLeading = new JButton();
409:                Component upperTrailing = new JButton();
410:                pane
411:                        .setCorner(ScrollPaneConstants.LOWER_LEFT_CORNER,
412:                                lowerLeft);
413:                assertTrue(propertyChangeController
414:                        .isChanged(ScrollPaneConstants.LOWER_LEFT_CORNER));
415:                assertEquals(4, pane.getComponentCount());
416:                propertyChangeController.reset();
417:                pane.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER,
418:                        lowerRight);
419:                assertTrue(propertyChangeController
420:                        .isChanged(ScrollPaneConstants.LOWER_RIGHT_CORNER));
421:                assertEquals(5, pane.getComponentCount());
422:                propertyChangeController.reset();
423:                pane
424:                        .setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER,
425:                                upperLeft);
426:                assertTrue(propertyChangeController
427:                        .isChanged(ScrollPaneConstants.UPPER_LEFT_CORNER));
428:                assertEquals(6, pane.getComponentCount());
429:                propertyChangeController.reset();
430:                pane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,
431:                        upperRight);
432:                assertTrue(propertyChangeController
433:                        .isChanged(ScrollPaneConstants.UPPER_RIGHT_CORNER));
434:                assertEquals(7, pane.getComponentCount());
435:                assertEquals(lowerLeft, pane
436:                        .getCorner(ScrollPaneConstants.LOWER_LEFT_CORNER));
437:                assertEquals(lowerRight, pane
438:                        .getCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER));
439:                assertEquals(upperLeft, pane
440:                        .getCorner(ScrollPaneConstants.UPPER_LEFT_CORNER));
441:                assertEquals(upperRight, pane
442:                        .getCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER));
443:                propertyChangeController.reset();
444:                pane.setCorner(ScrollPaneConstants.LOWER_LEADING_CORNER,
445:                        lowerLeading);
446:                assertTrue(propertyChangeController
447:                        .isChanged(ScrollPaneConstants.LOWER_LEFT_CORNER));
448:                assertEquals(7, pane.getComponentCount());
449:                propertyChangeController.reset();
450:                pane.setCorner(ScrollPaneConstants.LOWER_TRAILING_CORNER,
451:                        lowerTrailing);
452:                assertTrue(propertyChangeController
453:                        .isChanged(ScrollPaneConstants.LOWER_RIGHT_CORNER));
454:                assertEquals(7, pane.getComponentCount());
455:                propertyChangeController.reset();
456:                pane.setCorner(ScrollPaneConstants.UPPER_LEADING_CORNER,
457:                        upperLeading);
458:                assertTrue(propertyChangeController
459:                        .isChanged(ScrollPaneConstants.UPPER_LEFT_CORNER));
460:                assertEquals(7, pane.getComponentCount());
461:                propertyChangeController.reset();
462:                pane.setCorner(ScrollPaneConstants.UPPER_TRAILING_CORNER,
463:                        upperTrailing);
464:                assertTrue(propertyChangeController
465:                        .isChanged(ScrollPaneConstants.UPPER_RIGHT_CORNER));
466:                assertEquals(7, pane.getComponentCount());
467:                assertEquals(lowerLeading, pane
468:                        .getCorner(ScrollPaneConstants.LOWER_LEFT_CORNER));
469:                assertEquals(lowerTrailing, pane
470:                        .getCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER));
471:                assertEquals(upperLeading, pane
472:                        .getCorner(ScrollPaneConstants.UPPER_LEFT_CORNER));
473:                assertEquals(upperTrailing, pane
474:                        .getCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER));
475:                testExceptionalCase(new IllegalArgumentCase() {
476:                    @Override
477:                    public void exceptionalAction() throws Exception {
478:                        pane.setCorner("anything", null);
479:                    }
480:                });
481:                pane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,
482:                        new JButton());
483:                assertEquals(7, pane.getComponentCount());
484:                pane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, null);
485:                assertEquals(6, pane.getComponentCount());
486:                JButton b = new JButton();
487:                propertyChangeController.reset();
488:                pane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, b);
489:                assertTrue(propertyChangeController
490:                        .isChanged(ScrollPaneConstants.UPPER_RIGHT_CORNER));
491:                assertEquals(7, pane.getComponentCount());
492:                propertyChangeController.reset();
493:                pane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, b);
494:                assertFalse(propertyChangeController
495:                        .isChanged(ScrollPaneConstants.UPPER_RIGHT_CORNER));
496:                assertEquals(7, pane.getComponentCount());
497:                propertyChangeController.reset();
498:                pane.remove(6);
499:                pane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, b);
500:                assertFalse(propertyChangeController
501:                        .isChanged(ScrollPaneConstants.UPPER_RIGHT_CORNER));
502:                assertEquals(7, pane.getComponentCount());
503:            }
504:
505:            public void testSetComponentOrientation() throws Exception {
506:                assertTrue(pane.getComponentOrientation().isLeftToRight());
507:                assertTrue(pane.getVerticalScrollBar()
508:                        .getComponentOrientation().isLeftToRight());
509:                assertTrue(pane.getHorizontalScrollBar()
510:                        .getComponentOrientation().isLeftToRight());
511:                pane
512:                        .setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
513:                assertFalse(pane.getComponentOrientation().isLeftToRight());
514:                assertFalse(pane.getVerticalScrollBar()
515:                        .getComponentOrientation().isLeftToRight());
516:                assertFalse(pane.getHorizontalScrollBar()
517:                        .getComponentOrientation().isLeftToRight());
518:            }
519:
520:            public void testSetIsWhellScrollingEnabled() throws Exception {
521:                assertTrue(pane.isWheelScrollingEnabled());
522:                pane.setWheelScrollingEnabled(false);
523:                assertFalse(pane.isWheelScrollingEnabled());
524:                assertTrue(propertyChangeController
525:                        .isChanged("wheelScrollingEnabled"));
526:            }
527:
528:            public void testGetAccessibleContext() throws Exception {
529:                assertTrue(pane.getAccessibleContext() instanceof  JScrollPane.AccessibleJScrollPane);
530:            }
531:
532:            public void testIsOpaque() throws Exception {
533:                assertTrue(pane.isOpaque());
534:            }
535:
536:            private class TestLayout extends ScrollPaneLayout {
537:                private static final long serialVersionUID = 1L;
538:
539:                private JScrollPane syncScrollPane;
540:
541:                @Override
542:                public void syncWithScrollPane(final JScrollPane sp) {
543:                    super .syncWithScrollPane(sp);
544:                    syncScrollPane = sp;
545:                }
546:
547:                public JScrollPane getSyncScrollPane() {
548:                    return syncScrollPane;
549:                }
550:            }
551:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.