Source Code Cross Referenced for ScrollPaneLayout.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:        /**
019:         * @author Sergey Burlak
020:         * @version $Revision$
021:         */package javax.swing;
022:
023:        import java.awt.Component;
024:        import java.awt.Container;
025:        import java.awt.Dimension;
026:        import java.awt.Insets;
027:        import java.awt.LayoutManager;
028:        import java.awt.Rectangle;
029:        import java.io.Serializable;
030:
031:        import javax.swing.ScrollPaneConstants;
032:        import javax.swing.border.Border;
033:
034:        import org.apache.harmony.x.swing.internal.nls.Messages;
035:
036:        public class ScrollPaneLayout implements  Serializable, LayoutManager,
037:                ScrollPaneConstants {
038:
039:            public static class UIResource extends ScrollPaneLayout implements 
040:                    javax.swing.plaf.UIResource {
041:            }
042:
043:            protected JViewport viewport;
044:            protected JScrollBar vsb;
045:            protected JScrollBar hsb;
046:            protected JViewport rowHead;
047:            protected JViewport colHead;
048:            protected Component lowerLeft;
049:            protected Component lowerRight;
050:            protected Component upperLeft;
051:            protected Component upperRight;
052:            protected int vsbPolicy = VERTICAL_SCROLLBAR_AS_NEEDED;
053:            protected int hsbPolicy = HORIZONTAL_SCROLLBAR_AS_NEEDED;
054:
055:            protected Component addSingletonComponent(final Component oldC,
056:                    final Component newC) {
057:                if (oldC == null) {
058:                    return newC;
059:                }
060:
061:                Container parent = oldC.getParent();
062:                if (parent != null) {
063:                    parent.remove(oldC);
064:                }
065:
066:                return newC;
067:            }
068:
069:            public void addLayoutComponent(final String s, final Component c) {
070:                if (VIEWPORT.equals(s)) {
071:                    viewport = (JViewport) addSingletonComponent(viewport, c);
072:                } else if (VERTICAL_SCROLLBAR.equals(s)) {
073:                    vsb = (JScrollBar) addSingletonComponent(vsb, c);
074:                } else if (HORIZONTAL_SCROLLBAR.equals(s)) {
075:                    hsb = (JScrollBar) addSingletonComponent(hsb, c);
076:                } else if (ROW_HEADER.equals(s)) {
077:                    rowHead = (JViewport) addSingletonComponent(rowHead, c);
078:                } else if (COLUMN_HEADER.equals(s)) {
079:                    colHead = (JViewport) addSingletonComponent(colHead, c);
080:                } else if (LOWER_LEFT_CORNER.equals(s)) {
081:                    lowerLeft = addSingletonComponent(lowerLeft, c);
082:                } else if (LOWER_RIGHT_CORNER.equals(s)) {
083:                    lowerRight = addSingletonComponent(lowerRight, c);
084:                } else if (UPPER_LEFT_CORNER.equals(s)) {
085:                    upperLeft = addSingletonComponent(upperLeft, c);
086:                } else if (UPPER_RIGHT_CORNER.equals(s)) {
087:                    upperRight = addSingletonComponent(upperRight, c);
088:                }
089:            }
090:
091:            public void removeLayoutComponent(final Component c) {
092:                if (viewport == c) {
093:                    viewport = null;
094:                }
095:                if (vsb == c) {
096:                    vsb = null;
097:                }
098:                if (hsb == c) {
099:                    hsb = null;
100:                }
101:                if (rowHead == c) {
102:                    rowHead = null;
103:                }
104:                if (colHead == c) {
105:                    colHead = null;
106:                }
107:                if (lowerLeft == c) {
108:                    lowerLeft = null;
109:                }
110:                if (lowerRight == c) {
111:                    lowerRight = null;
112:                }
113:                if (upperLeft == c) {
114:                    upperLeft = null;
115:                }
116:                if (upperRight == c) {
117:                    upperRight = null;
118:                }
119:            }
120:
121:            public int getVerticalScrollBarPolicy() {
122:                return vsbPolicy;
123:            }
124:
125:            public void setVerticalScrollBarPolicy(final int x) {
126:                if (x != ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
127:                        && x != ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
128:                        && x != ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER) {
129:                    throw new IllegalArgumentException(Messages.getString(
130:                            "swing.02", "verticalScrollBarPolicy")); //$NON-NLS-1$ //$NON-NLS-2$
131:                }
132:                vsbPolicy = x;
133:            }
134:
135:            public int getHorizontalScrollBarPolicy() {
136:                return hsbPolicy;
137:            }
138:
139:            public void setHorizontalScrollBarPolicy(final int x) {
140:                if (x != ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
141:                        && x != ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
142:                        && x != ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
143:                    throw new IllegalArgumentException(Messages.getString(
144:                            "swing.02", "horizontalScrollBarPolicy")); //$NON-NLS-1$ //$NON-NLS-2$
145:                }
146:                hsbPolicy = x;
147:            }
148:
149:            public JViewport getViewport() {
150:                return viewport;
151:            }
152:
153:            public JScrollBar getHorizontalScrollBar() {
154:                return hsb;
155:            }
156:
157:            public JScrollBar getVerticalScrollBar() {
158:                return vsb;
159:            }
160:
161:            public JViewport getRowHeader() {
162:                return rowHead;
163:            }
164:
165:            public JViewport getColumnHeader() {
166:                return colHead;
167:            }
168:
169:            public Component getCorner(final String key) {
170:                if (LOWER_LEFT_CORNER.equals(key)) {
171:                    return lowerLeft;
172:                }
173:                if (UPPER_LEFT_CORNER.equals(key)) {
174:                    return upperLeft;
175:                }
176:                if (LOWER_RIGHT_CORNER.equals(key)) {
177:                    return lowerRight;
178:                }
179:                if (UPPER_RIGHT_CORNER.equals(key)) {
180:                    return upperRight;
181:                }
182:
183:                return null;
184:            }
185:
186:            public Dimension preferredLayoutSize(final Container parent) {
187:                JScrollPane pane = (JScrollPane) parent;
188:
189:                int rowHeadWidth = (rowHead == null) ? 0 : rowHead
190:                        .getPreferredSize().width;
191:                int viewportWidth = (viewport == null) ? 0 : viewport
192:                        .getPreferredSize().width;
193:                int viewportBorderLeft = (pane.getViewportBorder() == null) ? 0
194:                        : pane.getViewportBorder().getBorderInsets(pane).left;
195:                int viewportBorderRight = (pane.getViewportBorder() == null) ? 0
196:                        : pane.getViewportBorder().getBorderInsets(pane).right;
197:                int width = viewportWidth + rowHeadWidth
198:                        + (vsb == null ? 0 : vsb.getBounds().width)
199:                        + pane.getInsets().right + pane.getInsets().left
200:                        + viewportBorderLeft + viewportBorderRight;
201:
202:                int viewportHeight = (viewport == null) ? 0 : viewport
203:                        .getPreferredSize().height;
204:                int colHeadHeight = (colHead == null) ? 0 : colHead
205:                        .getPreferredSize().height;
206:                int viewportBorderTop = (pane.getViewportBorder() == null) ? 0
207:                        : pane.getViewportBorder().getBorderInsets(pane).top;
208:                int viewportBorderBottom = (pane.getViewportBorder() == null) ? 0
209:                        : pane.getViewportBorder().getBorderInsets(pane).bottom;
210:                int height = viewportHeight + colHeadHeight
211:                        + (hsb == null ? 0 : hsb.getBounds().height)
212:                        + pane.getInsets().top + pane.getInsets().bottom
213:                        + viewportBorderTop + viewportBorderBottom;
214:
215:                return new Dimension(width, height);
216:            }
217:
218:            public Dimension minimumLayoutSize(final Container parent) {
219:                JScrollPane pane = (JScrollPane) parent;
220:
221:                if (pane == null) {
222:                    return new Dimension(0, 0);
223:                }
224:
225:                int rowHeadWidth = (rowHead == null) ? 0 : rowHead
226:                        .getMinimumSize().width;
227:                int viewportWidth = (viewport == null) ? 0 : viewport
228:                        .getMinimumSize().width;
229:                int viewportBorderLeft = (pane.getViewportBorder() == null) ? 0
230:                        : pane.getViewportBorder().getBorderInsets(pane).left;
231:                int viewportBorderRight = (pane.getViewportBorder() == null) ? 0
232:                        : pane.getViewportBorder().getBorderInsets(pane).right;
233:                int vsbWidth = ((pane.getVerticalScrollBarPolicy() == VERTICAL_SCROLLBAR_NEVER) ? 0
234:                        : pane.getVerticalScrollBar().getMinimumSize().width);
235:                int width = viewportWidth + rowHeadWidth + vsbWidth
236:                        + pane.getInsets().right + pane.getInsets().left
237:                        + viewportBorderLeft + viewportBorderRight;
238:
239:                int viewportHeight = (viewport == null) ? 0 : viewport
240:                        .getMinimumSize().height;
241:                int colHeadHeight = (colHead == null) ? 0 : colHead
242:                        .getMinimumSize().height;
243:                int viewportBorderTop = (pane.getViewportBorder() == null) ? 0
244:                        : pane.getViewportBorder().getBorderInsets(pane).top;
245:                int viewportBorderBottom = (pane.getViewportBorder() == null) ? 0
246:                        : pane.getViewportBorder().getBorderInsets(pane).bottom;
247:                int hsbHeight = ((pane.getVerticalScrollBarPolicy() == HORIZONTAL_SCROLLBAR_NEVER) ? 0
248:                        : pane.getHorizontalScrollBar().getMinimumSize().height);
249:                int height = viewportHeight + colHeadHeight + hsbHeight
250:                        + pane.getInsets().top + pane.getInsets().bottom
251:                        + viewportBorderTop + viewportBorderBottom;
252:
253:                return new Dimension(width, height);
254:            }
255:
256:            public void layoutContainer(final Container parent) {
257:                JScrollPane pane = (JScrollPane) parent;
258:
259:                Insets scrollPaneInsets = pane.getInsets();
260:
261:                boolean isVerticalSBVisible = isVerticalScrollBarVisible(pane);
262:                if (vsb != null) {
263:                    vsb.setVisible(isVerticalSBVisible);
264:                    if (!isVerticalSBVisible) {
265:                        vsb.setBounds(0, 0, 0, 0);
266:                    }
267:                }
268:                boolean isHorizontalSBVisible = isHorizontalScrollBarVisible(pane);
269:                if (hsb != null) {
270:                    hsb.setVisible(isHorizontalSBVisible);
271:                    if (!isHorizontalSBVisible) {
272:                        hsb.setBounds(0, 0, 0, 0);
273:                    }
274:                }
275:
276:                int verticalSBWidth = isVerticalSBVisible && vsb != null ? vsb
277:                        .getPreferredSize().width : 0;
278:                int horizontalSBHeight = isHorizontalSBVisible && hsb != null ? hsb
279:                        .getPreferredSize().height
280:                        : 0;
281:
282:                int rowHeadWidth = (rowHead != null && rowHead.isVisible()) ? rowHead
283:                        .getPreferredSize().width
284:                        : 0;
285:                int colHeadHeight = (colHead != null && colHead.isVisible()) ? colHead
286:                        .getPreferredSize().height
287:                        : 0;
288:
289:                int rowHeadHeight = pane.getSize().height
290:                        - scrollPaneInsets.top - scrollPaneInsets.bottom
291:                        - colHeadHeight - horizontalSBHeight;
292:                int colHeadWidth = pane.getSize().width - scrollPaneInsets.left
293:                        - scrollPaneInsets.right - rowHeadWidth
294:                        - verticalSBWidth;
295:
296:                setRowHeadBounds(pane, rowHeadWidth, rowHeadHeight);
297:                setColHeadBounds(pane, verticalSBWidth, rowHeadWidth,
298:                        colHeadHeight, colHeadWidth);
299:
300:                setVSBBounds(pane, verticalSBWidth, horizontalSBHeight,
301:                        colHeadHeight);
302:                setHSBBounds(pane, verticalSBWidth, horizontalSBHeight,
303:                        rowHeadWidth);
304:
305:                setViewportBounds(pane, verticalSBWidth, horizontalSBHeight,
306:                        rowHeadWidth, colHeadHeight);
307:
308:                setUpperLeftBounds(pane, horizontalSBHeight, rowHeadWidth,
309:                        colHeadHeight);
310:                setLowerLeftBounds(pane, horizontalSBHeight, rowHeadWidth,
311:                        colHeadHeight, rowHeadHeight);
312:                setUpperRightBounds(pane, verticalSBWidth, rowHeadWidth,
313:                        colHeadHeight);
314:                setLowerRightBounds(pane, verticalSBWidth, horizontalSBHeight,
315:                        rowHeadWidth, colHeadHeight, rowHeadHeight);
316:            }
317:
318:            public Rectangle getViewportBorderBounds(
319:                    final JScrollPane scrollpane) {
320:                return scrollpane.getViewportBorderBounds();
321:            }
322:
323:            public void syncWithScrollPane(final JScrollPane sp) {
324:                viewport = sp.getViewport();
325:                rowHead = sp.getRowHeader();
326:                colHead = sp.getColumnHeader();
327:                vsb = sp.getVerticalScrollBar();
328:                hsb = sp.getHorizontalScrollBar();
329:                lowerLeft = sp.getCorner(LOWER_LEFT_CORNER);
330:                lowerRight = sp.getCorner(LOWER_RIGHT_CORNER);
331:                upperLeft = sp.getCorner(UPPER_LEFT_CORNER);
332:                upperRight = sp.getCorner(UPPER_RIGHT_CORNER);
333:                vsbPolicy = sp.getVerticalScrollBarPolicy();
334:                hsbPolicy = sp.getHorizontalScrollBarPolicy();
335:            }
336:
337:            private boolean isHorizontalScrollBarVisible(final JScrollPane pane) {
338:                if (getHorizontalScrollBarPolicy() == HORIZONTAL_SCROLLBAR_ALWAYS) {
339:                    return true;
340:                } else if (getHorizontalScrollBarPolicy() == HORIZONTAL_SCROLLBAR_NEVER
341:                        || viewport.getView() == null) {
342:                    return false;
343:                }
344:                if (viewport.getView() instanceof  Scrollable
345:                        && ((Scrollable) viewport.getView())
346:                                .getScrollableTracksViewportWidth()) {
347:                    return false;
348:                }
349:
350:                Insets scrollPaneInsets = pane.getInsets();
351:
352:                int rowHeadWidth = (rowHead != null && rowHead.isVisible()) ? rowHead
353:                        .getPreferredSize().width
354:                        : 0;
355:                int vsbWidth = vsb.isVisible() ? vsb.getWidth() : 0;
356:                int viewportWidth = pane.getSize().width
357:                        - scrollPaneInsets.left - scrollPaneInsets.right
358:                        - rowHeadWidth - vsbWidth;
359:
360:                Border viewportBorder = pane.getViewportBorder();
361:                if (viewportBorder != null) {
362:                    Insets viewportBorderInsets = viewportBorder
363:                            .getBorderInsets(viewport);
364:                    viewportWidth -= viewportBorderInsets.left
365:                            + viewportBorderInsets.right;
366:                }
367:
368:                return viewport.getView().getPreferredSize().width > viewportWidth;
369:            }
370:
371:            private boolean isVerticalScrollBarVisible(final JScrollPane pane) {
372:                if (getVerticalScrollBarPolicy() == VERTICAL_SCROLLBAR_ALWAYS) {
373:                    return true;
374:                } else if (getVerticalScrollBarPolicy() == VERTICAL_SCROLLBAR_NEVER
375:                        || viewport == null || viewport.getView() == null) {
376:                    return false;
377:                }
378:                if (viewport.getView() instanceof  Scrollable
379:                        && ((Scrollable) viewport.getView())
380:                                .getScrollableTracksViewportHeight()) {
381:                    return false;
382:                }
383:
384:                Insets scrollPaneInsets = pane.getInsets();
385:
386:                int colHeadHeight = (colHead != null && colHead.isVisible()) ? colHead
387:                        .getPreferredSize().height
388:                        : 0;
389:                int hsbHeight = hsb.isVisible() ? hsb.getHeight() : 0;
390:                int viewportHeight = pane.getSize().height
391:                        - scrollPaneInsets.top - scrollPaneInsets.bottom
392:                        - colHeadHeight - hsbHeight;
393:
394:                Border viewportBorder = pane.getViewportBorder();
395:                if (viewportBorder != null) {
396:                    Insets viewportBorderInsets = viewportBorder
397:                            .getBorderInsets(viewport);
398:                    viewportHeight -= viewportBorderInsets.top
399:                            + viewportBorderInsets.bottom;
400:                }
401:
402:                return viewport.getView().getPreferredSize().height > viewportHeight;
403:            }
404:
405:            private void setViewportBounds(final JScrollPane pane,
406:                    final int verticalSBWidth, final int horizontalSBHeight,
407:                    final int rowHeadWidth, final int colHeadHeight) {
408:
409:                Insets scrollPaneInsets = pane.getInsets();
410:                boolean leftToRight = pane.getComponentOrientation()
411:                        .isLeftToRight();
412:                int viewportX;
413:                int viewportY = scrollPaneInsets.top + colHeadHeight;
414:                int viewportWidth = pane.getSize().width
415:                        - scrollPaneInsets.left - scrollPaneInsets.right
416:                        - verticalSBWidth - rowHeadWidth;
417:                int viewportHeight = pane.getSize().height
418:                        - scrollPaneInsets.top - scrollPaneInsets.bottom
419:                        - colHeadHeight - horizontalSBHeight;
420:                if (leftToRight) {
421:                    viewportX = scrollPaneInsets.left + rowHeadWidth;
422:                } else {
423:                    viewportX = scrollPaneInsets.left + verticalSBWidth;
424:                }
425:                if (pane.getViewportBorder() != null) {
426:                    Insets viewportBorderInsets = pane.getViewportBorder()
427:                            .getBorderInsets(viewport);
428:                    viewportWidth -= viewportBorderInsets.left
429:                            + viewportBorderInsets.right;
430:                    viewportHeight -= viewportBorderInsets.top
431:                            + viewportBorderInsets.bottom;
432:                    viewportX += viewportBorderInsets.left;
433:                    viewportY += viewportBorderInsets.top;
434:                }
435:                viewportWidth = viewportWidth > 0 ? viewportWidth : 0;
436:                viewportHeight = viewportHeight > 0 ? viewportHeight : 0;
437:
438:                Rectangle newBounds = new Rectangle(viewportX, viewportY,
439:                        viewportWidth, viewportHeight);
440:
441:                if (!newBounds.equals(viewport.getBounds())) {
442:                    viewport.setLocation(viewportX, viewportY);
443:                    viewport.setExtentSize(new Dimension(viewportWidth,
444:                            viewportHeight));
445:                }
446:            }
447:
448:            private void setHSBBounds(final JScrollPane pane,
449:                    final int verticalSBWidth, final int horizontalSBHeight,
450:                    final int rowHeadWidth) {
451:
452:                if (hsb == null) {
453:                    return;
454:                }
455:
456:                Insets scrollPaneInsets = pane.getInsets();
457:                boolean leftToRight = pane.getComponentOrientation()
458:                        .isLeftToRight();
459:
460:                int hsbX;
461:                if (leftToRight) {
462:                    hsbX = scrollPaneInsets.left + rowHeadWidth;
463:                } else {
464:                    hsbX = scrollPaneInsets.left + verticalSBWidth;
465:                }
466:                int hsbY = pane.getSize().height - scrollPaneInsets.bottom
467:                        - horizontalSBHeight;
468:                int horizontalSBWidth = pane.getWidth() - scrollPaneInsets.left
469:                        - scrollPaneInsets.right - rowHeadWidth
470:                        - verticalSBWidth;
471:                hsb
472:                        .setBounds(hsbX, hsbY, horizontalSBWidth,
473:                                horizontalSBHeight);
474:            }
475:
476:            private void setVSBBounds(final JScrollPane pane,
477:                    final int verticalSBWidth, final int horizontalSBHeight,
478:                    final int colHeadHeight) {
479:
480:                if (vsb == null) {
481:                    return;
482:                }
483:
484:                Insets scrollPaneInsets = pane.getInsets();
485:                boolean leftToRight = pane.getComponentOrientation()
486:                        .isLeftToRight();
487:
488:                int vsbX;
489:                if (leftToRight) {
490:                    vsbX = pane.getSize().width - scrollPaneInsets.right
491:                            - verticalSBWidth;
492:                } else {
493:                    vsbX = scrollPaneInsets.left;
494:                }
495:                int vsbY = scrollPaneInsets.top + colHeadHeight;
496:                int verticalSBHeight = pane.getHeight() - scrollPaneInsets.top
497:                        - scrollPaneInsets.bottom - horizontalSBHeight
498:                        - colHeadHeight;
499:                vsb.setBounds(vsbX, vsbY, verticalSBWidth, verticalSBHeight);
500:            }
501:
502:            private void setColHeadBounds(final JScrollPane pane,
503:                    final int verticalSBWidth, final int rowHeadWidth,
504:                    final int colHeadHeight, final int colHeadWidth) {
505:
506:                if (colHead == null || !colHead.isVisible()) {
507:                    return;
508:                }
509:
510:                Insets scrollPaneInsets = pane.getInsets();
511:                boolean leftToRight = pane.getComponentOrientation()
512:                        .isLeftToRight();
513:
514:                int colHeadX = (leftToRight) ? scrollPaneInsets.left
515:                        + rowHeadWidth : scrollPaneInsets.left
516:                        + verticalSBWidth;
517:                int colHeadY = scrollPaneInsets.top;
518:
519:                colHead.setBounds(colHeadX, colHeadY, colHeadWidth,
520:                        colHeadHeight);
521:            }
522:
523:            private void setRowHeadBounds(final JScrollPane pane,
524:                    final int rowHeadWidth, final int rowHeadHeight) {
525:                if (rowHead == null || !rowHead.isVisible()) {
526:                    return;
527:                }
528:
529:                Insets scrollPaneInsets = pane.getInsets();
530:                boolean leftToRight = pane.getComponentOrientation()
531:                        .isLeftToRight();
532:
533:                int rowHeadX = (leftToRight) ? scrollPaneInsets.left : pane
534:                        .getSize().width
535:                        - scrollPaneInsets.right
536:                        - rowHead.getPreferredSize().width;
537:                int rowHeadY = (colHead != null && colHead.isVisible()) ? scrollPaneInsets.top
538:                        + colHead.getPreferredSize().height
539:                        : scrollPaneInsets.top;
540:
541:                rowHead.setBounds(rowHeadX, rowHeadY, rowHeadWidth,
542:                        rowHeadHeight);
543:            }
544:
545:            private void setLowerRightBounds(final JScrollPane pane,
546:                    final int verticalSBWidth, final int horizontalSBHeight,
547:                    final int rowHeadWidth, final int colHeadHeight,
548:                    final int rowHeadHeight) {
549:
550:                Insets scrollPaneInsets = pane.getInsets();
551:                boolean leftToRight = pane.getComponentOrientation()
552:                        .isLeftToRight();
553:
554:                if (lowerRight != null) {
555:                    if (((vsb.isVisible() && leftToRight) || (rowHead != null
556:                            && rowHead.isVisible() && !leftToRight))
557:                            && hsb.isVisible()) {
558:                        int lowerRigthX = leftToRight ? vsb.getX() : rowHead
559:                                .getX();
560:                        int lowerRightWidth = leftToRight ? verticalSBWidth
561:                                : rowHeadWidth;
562:                        lowerRight.setBounds(lowerRigthX, scrollPaneInsets.top
563:                                + colHeadHeight + rowHeadHeight,
564:                                lowerRightWidth, horizontalSBHeight);
565:                    } else {
566:                        lowerRight.setBounds(0, 0, 0, 0);
567:                    }
568:                }
569:            }
570:
571:            private void setUpperRightBounds(final JScrollPane pane,
572:                    final int verticalSBWidth, final int rowHeadWidth,
573:                    final int colHeadHeight) {
574:                Insets scrollPaneInsets = pane.getInsets();
575:                boolean leftToRight = pane.getComponentOrientation()
576:                        .isLeftToRight();
577:
578:                if (upperRight != null) {
579:                    if (colHead != null
580:                            && colHead.isVisible()
581:                            && ((vsb.isVisible() && leftToRight) || (rowHead != null
582:                                    && rowHead.isVisible() && !leftToRight))) {
583:                        int upperRightWidth = leftToRight ? verticalSBWidth
584:                                : rowHeadWidth;
585:                        int upperRightX = leftToRight ? pane.getWidth()
586:                                - scrollPaneInsets.right - verticalSBWidth
587:                                : pane.getWidth() - scrollPaneInsets.right
588:                                        - rowHeadWidth;
589:                        upperRight.setBounds(upperRightX, scrollPaneInsets.top,
590:                                upperRightWidth, colHeadHeight);
591:                    } else {
592:                        upperRight.setBounds(0, 0, 0, 0);
593:                    }
594:                }
595:            }
596:
597:            private void setLowerLeftBounds(final JScrollPane pane,
598:                    final int horizontalSBHeight, final int rowHeadWidth,
599:                    final int colHeadHeight, final int rowHeadHeight) {
600:                Insets scrollPaneInsets = pane.getInsets();
601:                boolean leftToRight = pane.getComponentOrientation()
602:                        .isLeftToRight();
603:
604:                if (lowerLeft != null) {
605:                    if (((rowHead != null && rowHead.isVisible() && leftToRight) || (vsb
606:                            .isVisible() && !leftToRight))
607:                            && hsb.isVisible()) {
608:                        int lowerLeftWidth = leftToRight ? rowHeadWidth
609:                                : horizontalSBHeight;
610:                        lowerLeft.setBounds(scrollPaneInsets.left,
611:                                scrollPaneInsets.top + colHeadHeight
612:                                        + rowHeadHeight, lowerLeftWidth,
613:                                horizontalSBHeight);
614:                    } else {
615:                        lowerLeft.setBounds(0, 0, 0, 0);
616:                    }
617:                }
618:            }
619:
620:            private void setUpperLeftBounds(final JScrollPane pane,
621:                    final int horizontalSBHeight, final int rowHeadWidth,
622:                    final int colHeadHeight) {
623:                Insets scrollPaneInsets = pane.getInsets();
624:                boolean leftToRight = pane.getComponentOrientation()
625:                        .isLeftToRight();
626:
627:                if (upperLeft != null) {
628:                    if (colHead != null
629:                            && colHead.isVisible()
630:                            && ((rowHead != null && rowHead.isVisible() && leftToRight) || (vsb
631:                                    .isVisible() && !leftToRight))) {
632:                        int upperLeftWidth = leftToRight ? rowHeadWidth
633:                                : horizontalSBHeight;
634:                        upperLeft.setBounds(scrollPaneInsets.left,
635:                                scrollPaneInsets.top, upperLeftWidth,
636:                                colHeadHeight);
637:                    } else {
638:                        upperLeft.setBounds(0, 0, 0, 0);
639:                    }
640:                }
641:            }
642:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.