1:
37:
38:
39: package ;
40:
41: import ;
42:
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54: import ;
55: import ;
56: import ;
57: import ;
58: import ;
59: import ;
60: import ;
61: import ;
62:
63: import ;
64: import ;
65: import ;
66: import ;
67: import ;
68: import ;
69: import ;
70: import ;
71: import ;
72: import ;
73: import ;
74: import ;
75: import ;
76: import ;
77: import ;
78: import ;
79: import ;
80:
81:
84: public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
85: {
86:
93: public class FocusHandler extends FocusAdapter
94: {
95:
100: public void focusGained(FocusEvent e)
101: {
102:
103: }
104:
105:
110: public void focusLost(FocusEvent e)
111: {
112:
113: }
114: }
115:
116:
125: public class MouseHandler extends MouseAdapter
126: {
127:
133: public void mousePressed(MouseEvent e)
134: {
135: if (tabPane.isEnabled())
136: {
137: int index = tabForCoordinate(tabPane, e.getX(), e.getY());
138: if (index >= 0 && tabPane.isEnabledAt(index))
139: {
140: tabPane.setSelectedIndex(index);
141: }
142: }
143: }
144:
145:
151: public void mouseEntered(MouseEvent ev)
152: {
153: int tabIndex = tabForCoordinate(tabPane, ev.getX(), ev.getY());
154: setRolloverTab(tabIndex);
155: }
156:
157:
163: public void mouseExited(MouseEvent ev)
164: {
165: setRolloverTab(-1);
166: }
167:
168:
174: public void mouseMoved(MouseEvent ev)
175: {
176: int tabIndex = tabForCoordinate(tabPane, ev.getX(), ev.getY());
177: setRolloverTab(tabIndex);
178: }
179: }
180:
181:
188: public class PropertyChangeHandler implements PropertyChangeListener
189: {
190:
196: public void propertyChange(PropertyChangeEvent e)
197: {
198: if (e.getPropertyName().equals("tabLayoutPolicy"))
199: {
200: layoutManager = createLayoutManager();
201:
202: tabPane.setLayout(layoutManager);
203: }
204: else if (e.getPropertyName().equals("tabPlacement")
205: && tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
206: {
207: incrButton = createIncreaseButton();
208: decrButton = createDecreaseButton();
209: }
210: tabPane.revalidate();
211: tabPane.repaint();
212: }
213: }
214:
215:
224: public class TabbedPaneLayout implements LayoutManager
225: {
226:
232: public void addLayoutComponent(String name, Component comp)
233: {
234:
235: }
236:
237:
241: public void calculateLayoutInfo()
242: {
243: int count = tabPane.getTabCount();
244: assureRectsCreated(count);
245: calculateTabRects(tabPane.getTabPlacement(), count);
246: tabRunsDirty = false;
247: }
248:
249:
257: protected Dimension calculateSize(boolean minimum)
258: {
259: int tabPlacement = tabPane.getTabPlacement();
260:
261: int width = 0;
262: int height = 0;
263: Component c;
264: Dimension dims;
265:
266:
267:
268: for (int i = 0; i < tabPane.getTabCount(); i++)
269: {
270: c = tabPane.getComponentAt(i);
271: if (c == null)
272: continue;
273: dims = minimum ? c.getMinimumSize() : c.getPreferredSize();
274: if (dims != null)
275: {
276: height = Math.max(height, dims.height);
277: width = Math.max(width, dims.width);
278: }
279: }
280:
281: Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
282: if (tabPlacement == SwingConstants.TOP
283: || tabPlacement == SwingConstants.BOTTOM)
284: {
285: int min = calculateMaxTabWidth(tabPlacement);
286: width = Math.max(min, width);
287: int tabAreaHeight = preferredTabAreaHeight(tabPlacement,
288: width - tabAreaInsets.left
289: - tabAreaInsets.right);
290: height += tabAreaHeight;
291: }
292: else
293: {
294: int min = calculateMaxTabHeight(tabPlacement);
295: height = Math.max(min, height);
296: int tabAreaWidth = preferredTabAreaWidth(tabPlacement,
297: height - tabAreaInsets.top
298: - tabAreaInsets.bottom);
299: width += tabAreaWidth;
300: }
301:
302: Insets tabPaneInsets = tabPane.getInsets();
303: return new Dimension(width + tabPaneInsets.left + tabPaneInsets.right,
304: height + tabPaneInsets.top + tabPaneInsets.bottom);
305: }
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
325: protected void calculateTabRects(int tabPlacement, int tabCount)
326: {
327: Insets insets = tabPane.getInsets();
328: Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
329: Dimension size = tabPane.getSize();
330:
331:
332: int x;
333: int y;
334:
335: int breakAt;
336:
337:
338: switch (tabPlacement)
339: {
340: case LEFT:
341: maxTabWidth = calculateMaxTabWidth(tabPlacement);
342: x = insets.left + tabAreaInsets.left;
343: y = insets.top + tabAreaInsets.top;
344: breakAt = size.height - (insets.bottom + tabAreaInsets.bottom);
345: break;
346: case RIGHT:
347: maxTabWidth = calculateMaxTabWidth(tabPlacement);
348: x = size.width - (insets.right + tabAreaInsets.right) - maxTabWidth;
349: y = insets.top + tabAreaInsets.top;
350: breakAt = size.height - (insets.bottom + tabAreaInsets.bottom);
351: break;
352: case BOTTOM:
353: maxTabHeight = calculateMaxTabHeight(tabPlacement);
354: x = insets.left + tabAreaInsets.left;
355: y = size.height - (insets.bottom + tabAreaInsets.bottom)
356: - maxTabHeight;
357: breakAt = size.width - (insets.right + tabAreaInsets.right);
358: break;
359: case TOP:
360: default:
361: maxTabHeight = calculateMaxTabHeight(tabPlacement);
362: x = insets.left + tabAreaInsets.left;
363: y = insets.top + tabAreaInsets.top;
364: breakAt = size.width - (insets.right + tabAreaInsets.right);
365: break;
366: }
367:
368: if (tabCount == 0)
369: return;
370:
371: FontMetrics fm = getFontMetrics();
372: runCount = 0;
373: selectedRun = -1;
374: int selectedIndex = tabPane.getSelectedIndex();
375:
376: Rectangle rect;
377:
378:
379: if (tabPlacement == SwingConstants.TOP
380: || tabPlacement == SwingConstants.BOTTOM)
381: {
382: for (int i = 0; i < tabCount; i++)
383: {
384: rect = rects[i];
385: if (i > 0)
386: {
387: rect.x = rects[i - 1].x + rects[i - 1].width;
388: }
389: else
390: {
391: tabRuns[0] = 0;
392: runCount = 1;
393: maxTabWidth = 0;
394: rect.x = x;
395: }
396: rect.width = calculateTabWidth(tabPlacement, i, fm);
397: maxTabWidth = Math.max(maxTabWidth, rect.width);
398:
399: if (rect.x != 2 + insets.left && rect.x + rect.width > breakAt)
400: {
401: if (runCount > tabRuns.length - 1)
402: expandTabRunsArray();
403: tabRuns[runCount] = i;
404: runCount++;
405: rect.x = x;
406: }
407:
408: rect.y = y;
409: rect.height = maxTabHeight;
410: if (i == selectedIndex)
411: selectedRun = runCount - 1;
412:
413: }
414: }
415: else
416: {
417: for (int i = 0; i < tabCount; i++)
418: {
419: rect = rects[i];
420: if (i > 0)
421: {
422: rect.y = rects[i - 1].y + rects[i - 1].height;
423: }
424: else
425: {
426: tabRuns[0] = 0;
427: runCount = 1;
428: maxTabHeight = 0;
429: rect.y = y;
430: }
431: rect.height = calculateTabHeight(tabPlacement, i,
432: fm.getHeight());
433: maxTabHeight = Math.max(maxTabHeight, rect.height);
434:
435: if (rect.y != 2 + insets.top && rect.y + rect.height > breakAt)
436: {
437: if (runCount > tabRuns.length - 1)
438: expandTabRunsArray();
439: tabRuns[runCount] = i;
440: runCount++;
441: rect.y = y;
442: }
443:
444: rect.x = x;
445: rect.width = maxTabWidth;
446:
447: if (i == selectedIndex)
448: selectedRun = runCount - 1;
449: }
450: }
451:
452: if (runCount > 1)
453: {
454: int start;
455: if (tabPlacement == SwingConstants.TOP
456: || tabPlacement == SwingConstants.BOTTOM)
457: start = y;
458: else
459: start = x;
460: normalizeTabRuns(tabPlacement, tabCount, start, breakAt);
461: selectedRun = getRunForTab(tabCount, selectedIndex);
462: if (shouldRotateTabRuns(tabPlacement))
463: {
464: rotateTabRuns(tabPlacement, selectedRun);
465: }
466: }
467:
468:
469: int tabRunOverlay = getTabRunOverlay(tabPlacement);
470: for (int i = runCount - 1; i >= 0; --i)
471: {
472: int start = tabRuns[i];
473: int nextIndex;
474: if (i == runCount - 1)
475: nextIndex = 0;
476: else
477: nextIndex = i + 1;
478: int next = tabRuns[nextIndex];
479: int end = next != 0 ? next - 1 : tabCount - 1;
480: if (tabPlacement == SwingConstants.TOP
481: || tabPlacement == SwingConstants.BOTTOM)
482: {
483: for (int j = start; j <= end; ++j)
484: {
485: rect = rects[j];
486: rect.y = y;
487: rect.x += getTabRunIndent(tabPlacement, i);
488: }
489: if (shouldPadTabRun(tabPlacement, i))
490: {
491: padTabRun(tabPlacement, start, end, breakAt);
492: }
493: if (tabPlacement == BOTTOM)
494: y -= maxTabHeight - tabRunOverlay;
495: else
496: y += maxTabHeight - tabRunOverlay;
497: }
498: else
499: {
500: for (int j = start; j <= end; ++j)
501: {
502: rect = rects[j];
503: rect.x = x;
504: rect.y += getTabRunIndent(tabPlacement, i);
505: }
506: if (shouldPadTabRun(tabPlacement, i))
507: {
508: padTabRun(tabPlacement, start, end, breakAt);
509: }
510: if (tabPlacement == RIGHT)
511: x -= maxTabWidth - tabRunOverlay;
512: else
513: x += maxTabWidth - tabRunOverlay;
514:
515: }
516: }
517: padSelectedTab(tabPlacement, selectedIndex);
518: }
519:
520:
527: public void layoutContainer(Container parent)
528: {
529: calculateLayoutInfo();
530:
531: int tabPlacement = tabPane.getTabPlacement();
532: Insets insets = tabPane.getInsets();
533:
534: int selectedIndex = tabPane.getSelectedIndex();
535:
536: Component selectedComponent = null;
537: if (selectedIndex >= 0)
538: selectedComponent = tabPane.getComponentAt(selectedIndex);
539:
540:
541:
542: if (selectedComponent != null)
543: {
544: setVisibleComponent(selectedComponent);
545: }
546:
547: int childCount = tabPane.getComponentCount();
548: if (childCount > 0)
549: {
550: int compX;
551: int compY;
552: int tabAreaWidth = 0;
553: int tabAreaHeight = 0;
554: switch (tabPlacement)
555: {
556: case LEFT:
557: tabAreaWidth = calculateTabAreaWidth(tabPlacement, runCount,
558: maxTabWidth);
559: compX = tabAreaWidth + insets.left + contentBorderInsets.left;
560: compY = insets.top + contentBorderInsets.top;
561: break;
562: case RIGHT:
563: tabAreaWidth = calculateTabAreaWidth(tabPlacement, runCount,
564: maxTabWidth);
565: compX = insets.left + contentBorderInsets.left;
566: compY = insets.top + contentBorderInsets.top;
567: break;
568: case BOTTOM:
569: tabAreaHeight = calculateTabAreaHeight(tabPlacement, runCount,
570: maxTabHeight);
571: compX = insets.left + contentBorderInsets.left;
572: compY = insets.top + contentBorderInsets.top;
573: break;
574: case TOP:
575: default:
576: tabAreaHeight = calculateTabAreaHeight(tabPlacement, runCount,
577: maxTabHeight);
578: compX = insets.left + contentBorderInsets.left;
579: compY = tabAreaHeight + insets.top + contentBorderInsets.top;
580: }
581: Rectangle bounds = tabPane.getBounds();
582: int compWidth = bounds.width - tabAreaWidth - insets.left
583: - insets.right - contentBorderInsets.left
584: - contentBorderInsets.right;
585: int compHeight = bounds.height - tabAreaHeight - insets.top
586: - insets.bottom - contentBorderInsets.top
587: - contentBorderInsets.bottom;
588:
589:
590: for (int i = 0; i < childCount; ++i)
591: {
592: Component c = tabPane.getComponent(i);
593: c.setBounds(compX, compY, compWidth, compHeight);
594: }
595: }
596: }
597:
598:
605: public Dimension minimumLayoutSize(Container parent)
606: {
607: return calculateSize(false);
608: }
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
627: protected void normalizeTabRuns(int tabPlacement, int tabCount, int start,
628: int max)
629: {
630: Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
631: if (tabPlacement == SwingUtilities.TOP
632: || tabPlacement == SwingUtilities.BOTTOM)
633: {
634:
635:
636: for (int i = 1; i < runCount; i++)
637: {
638: Rectangle currRun = rects[lastTabInRun(tabCount, i)];
639: Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))];
640: int spaceInCurr = currRun.x + currRun.width;
641: int spaceInNext = nextRun.x + nextRun.width;
642:
643: int diffNow = spaceInCurr - spaceInNext;
644: int diffLater = (spaceInCurr - currRun.width)
645: - (spaceInNext + currRun.width);
646: while (Math.abs(diffLater) < Math.abs(diffNow)
647: && spaceInNext + currRun.width < max)
648: {
649: tabRuns[i]--;
650: spaceInNext += currRun.width;
651: spaceInCurr -= currRun.width;
652: currRun = rects[lastTabInRun(tabCount, i)];
653: diffNow = spaceInCurr - spaceInNext;
654: diffLater = (spaceInCurr - currRun.width)
655: - (spaceInNext + currRun.width);
656: }
657:
658:
659: int first = lastTabInRun(tabCount, i) + 1;
660: int last = lastTabInRun(tabCount, getNextTabRun(i));
661: int currX = tabAreaInsets.left;
662: for (int j = first; j <= last; j++)
663: {
664: rects[j].x = currX;
665: currX += rects[j].width;
666: }
667: }
668: }
669: else
670: {
671: for (int i = 1; i < runCount; i++)
672: {
673: Rectangle currRun = rects[lastTabInRun(tabCount, i)];
674: Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))];
675: int spaceInCurr = currRun.y + currRun.height;
676: int spaceInNext = nextRun.y + nextRun.height;
677:
678: int diffNow = spaceInCurr - spaceInNext;
679: int diffLater = (spaceInCurr - currRun.height)
680: - (spaceInNext + currRun.height);
681: while (Math.abs(diffLater) < Math.abs(diffNow)
682: && spaceInNext + currRun.height < max)
683: {
684: tabRuns[i]--;
685: spaceInNext += currRun.height;
686: spaceInCurr -= currRun.height;
687: currRun = rects[lastTabInRun(tabCount, i)];
688: diffNow = spaceInCurr - spaceInNext;
689: diffLater = (spaceInCurr - currRun.height)
690: - (spaceInNext + currRun.height);
691: }
692:
693: int first = lastTabInRun(tabCount, i) + 1;
694: int last = lastTabInRun(tabCount, getNextTabRun(i));
695: int currY = tabAreaInsets.top;
696: for (int j = first; j <= last; j++)
697: {
698: rects[j].y = currY;
699: currY += rects[j].height;
700: }
701: }
702: }
703: }
704:
705:
712: protected void padSelectedTab(int tabPlacement, int selectedIndex)
713: {
714: Insets insets = getSelectedTabPadInsets(tabPlacement);
715: rects[selectedIndex].x -= insets.left;
716: rects[selectedIndex].y -= insets.top;
717: rects[selectedIndex].width += insets.left + insets.right;
718: rects[selectedIndex].height += insets.top + insets.bottom;
719: }
720:
721:
722:
723:
724:
725:
726:
727:
737: protected void padTabRun(int tabPlacement, int start, int end, int max)
738: {
739: if (tabPlacement == SwingConstants.TOP
740: || tabPlacement == SwingConstants.BOTTOM)
741: {
742: int runWidth = rects[end].x + rects[end].width;
743: int spaceRemaining = max - runWidth;
744: int numTabs = end - start + 1;
745:
746:
747: int spaceAllocated = spaceRemaining / numTabs;
748: int currX = rects[start].x;
749: for (int i = start; i <= end; i++)
750: {
751: rects[i].x = currX;
752: rects[i].width += spaceAllocated;
753: currX += rects[i].width;
754:
755:
756:
757:
758: if (i == end && rects[i].x + rects[i].width != max)
759: rects[i].width = max - rects[i].x;
760: }
761: }
762: else
763: {
764: int runHeight = rects[end].y + rects[end].height;
765: int spaceRemaining = max - runHeight;
766: int numTabs = end - start + 1;
767:
768: int spaceAllocated = spaceRemaining / numTabs;
769: int currY = rects[start].y;
770: for (int i = start; i <= end; i++)
771: {
772: rects[i].y = currY;
773: rects[i].height += spaceAllocated;
774: currY += rects[i].height;
775: if (i == end && rects[i].y + rects[i].height != max)
776: rects[i].height = max - rects[i].y;
777: }
778: }
779: }
780:
781:
788: public Dimension preferredLayoutSize(Container parent)
789: {
790: return calculateSize(false);
791: }
792:
793:
802: protected int preferredTabAreaHeight(int tabPlacement, int width)
803: {
804: if (tabPane.getTabCount() == 0)
805: return calculateTabAreaHeight(tabPlacement, 0, 0);
806:
807: int runs = 0;
808: int runWidth = 0;
809: int tabWidth = 0;
810:
811: FontMetrics fm = getFontMetrics();
812:
813: Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
814: Insets insets = tabPane.getInsets();
815:
816:
817: width -= tabAreaInsets.left + tabAreaInsets.right + insets.left
818: + insets.right;
819:
820:
821:
822:
823:
824:
825: for (int i = 0; i < tabPane.getTabCount(); i++)
826: {
827: tabWidth = calculateTabWidth(tabPlacement, i, fm);
828: if (runWidth + tabWidth > width)
829: {
830: runWidth = tabWidth;
831: runs++;
832: }
833: else
834: runWidth += tabWidth;
835: }
836: runs++;
837:
838: int maxTabHeight = calculateMaxTabHeight(tabPlacement);
839: int tabAreaHeight = calculateTabAreaHeight(tabPlacement, runs,
840: maxTabHeight);
841: return tabAreaHeight;
842: }
843:
844:
853: protected int preferredTabAreaWidth(int tabPlacement, int height)
854: {
855: if (tabPane.getTabCount() == 0)
856: return calculateTabAreaHeight(tabPlacement, 0, 0);
857:
858: int runs = 0;
859: int runHeight = 0;
860: int tabHeight = 0;
861:
862: FontMetrics fm = getFontMetrics();
863:
864: Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
865: Insets insets = tabPane.getInsets();
866:
867: height -= tabAreaInsets.top + tabAreaInsets.bottom + insets.top
868: + insets.bottom;
869: int fontHeight = fm.getHeight();
870:
871: for (int i = 0; i < tabPane.getTabCount(); i++)
872: {
873: tabHeight = calculateTabHeight(tabPlacement, i, fontHeight);
874: if (runHeight + tabHeight > height)
875: {
876: runHeight = tabHeight;
877: runs++;
878: }
879: else
880: runHeight += tabHeight;
881: }
882: runs++;
883:
884: int maxTabWidth = calculateMaxTabWidth(tabPlacement);
885: int tabAreaWidth = calculateTabAreaWidth(tabPlacement, runs, maxTabWidth);
886: return tabAreaWidth;
887: }
888:
889:
897: protected void rotateTabRuns(int tabPlacement, int selectedRun)
898: {
899: if (runCount == 1 || selectedRun == 1 || selectedRun == -1)
900: return;
901: int[] newTabRuns = new int[tabRuns.length];
902: int currentRun = selectedRun;
903: int i = 1;
904: do
905: {
906: newTabRuns[i] = tabRuns[currentRun];
907: currentRun = getNextTabRun(currentRun);
908: i++;
909: }
910: while (i < runCount);
911: if (runCount > 1)
912: newTabRuns[0] = tabRuns[currentRun];
913:
914: tabRuns = newTabRuns;
915: BasicTabbedPaneUI.this.selectedRun = 1;
916: }
917:
918:
924: public void removeLayoutComponent(Component comp)
925: {
926:
927: }
928: }
929:
930:
934: private class TabbedPaneScrollLayout extends TabbedPaneLayout
935: {
936:
943: public Dimension preferredLayoutSize(Container parent)
944: {
945: return super.calculateSize(true);
946: }
947:
948:
955: public Dimension minimumLayoutSize(Container parent)
956: {
957: return super.calculateSize(true);
958: }
959:
960:
968: protected int preferredTabAreaHeight(int tabPlacement, int width)
969: {
970: if (tabPane.getTabCount() == 0)
971: return calculateTabAreaHeight(tabPlacement, 0, 0);
972:
973: int runs = 1;
974:
975: int maxTabHeight = calculateMaxTabHeight(tabPlacement);
976: int tabAreaHeight = calculateTabAreaHeight(tabPlacement, runs,
977: maxTabHeight);
978: return tabAreaHeight;
979: }
980:
981:
989: protected int preferredTabAreaWidth(int tabPlacement, int height)
990: {
991: if (tabPane.getTabCount() == 0)
992: return calculateTabAreaHeight(tabPlacement, 0, 0);
993:
994: int runs = 1;
995:
996: int maxTabWidth = calculateMaxTabWidth(tabPlacement);
997: int tabAreaWidth = calculateTabAreaWidth(tabPlacement, runs, maxTabWidth);
998: return tabAreaWidth;
999: }
1000:
1001:
1010: protected void calculateTabRects(int tabPlacement, int tabCount)
1011: {
1012: if (tabCount == 0)
1013: return;
1014:
1015: FontMetrics fm = getFontMetrics();
1016: SwingUtilities.calculateInnerArea(tabPane, calcRect);
1017: Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
1018: Insets insets = tabPane.getInsets();
1019: int runs = 1;
1020: int start = 0;
1021: int top = 0;
1022: if (tabPlacement == SwingConstants.TOP
1023: || tabPlacement == SwingConstants.BOTTOM)
1024: {
1025: int maxHeight = calculateMaxTabHeight(tabPlacement);
1026: calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;
1027: start = tabAreaInsets.left + insets.left;
1028: int width = 0;
1029: int runWidth = start;
1030: top = insets.top + tabAreaInsets.top;
1031: for (int i = 0; i < tabCount; i++)
1032: {
1033: width = calculateTabWidth(tabPlacement, i, fm);
1034:
1035: rects[i] = new Rectangle(runWidth, top, width, maxHeight);
1036: runWidth += width;
1037: }
1038: tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right;
1039: tabAreaRect.height = runs * maxTabHeight
1040: - (runs - 1) * tabRunOverlay
1041: + tabAreaInsets.top + tabAreaInsets.bottom;
1042: contentRect.width = tabAreaRect.width;
1043: contentRect.height = tabPane.getHeight() - insets.top
1044: - insets.bottom - tabAreaRect.height;
1045: contentRect.x = insets.left;
1046: tabAreaRect.x = insets.left;
1047: if (tabPlacement == SwingConstants.BOTTOM)
1048: {
1049: contentRect.y = insets.top;
1050: tabAreaRect.y = contentRect.y + contentRect.height;
1051: }
1052: else
1053: {
1054: tabAreaRect.y = insets.top;
1055: contentRect.y = tabAreaRect.y + tabAreaRect.height;
1056: }
1057: }
1058: else
1059: {
1060: int maxWidth = calculateMaxTabWidth(tabPlacement);
1061:
1062: calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom;
1063: int height = 0;
1064: start = tabAreaInsets.top + insets.top;
1065: int runHeight = start;
1066: int fontHeight = fm.getHeight();
1067: top = insets.left + tabAreaInsets.left;
1068: for (int i = 0; i < tabCount; i++)
1069: {
1070: height = calculateTabHeight(tabPlacement, i, fontHeight);
1071: rects[i] = new Rectangle(top, runHeight, maxWidth, height);
1072: runHeight += height;
1073: }
1074: tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay
1075: + tabAreaInsets.left + tabAreaInsets.right;
1076: tabAreaRect.height = tabPane.getHeight() - insets.top
1077: - insets.bottom;
1078: tabAreaRect.y = insets.top;
1079: contentRect.width = tabPane.getWidth() - insets.left - insets.right
1080: - tabAreaRect.width;
1081: contentRect.height = tabAreaRect.height;
1082: contentRect.y = insets.top;
1083: if (tabPlacement == SwingConstants.LEFT)
1084: {
1085: tabAreaRect.x = insets.left;
1086: contentRect.x = tabAreaRect.x + tabAreaRect.width;
1087: }
1088: else
1089: {
1090: contentRect.x = insets.left;
1091: tabAreaRect.x = contentRect.x + contentRect.width;
1092: }
1093: }
1094: runCount = runs;
1095: if (runCount > tabRuns.length)
1096: expandTabRunsArray();
1097:
1098: padSelectedTab(tabPlacement, tabPane.getSelectedIndex());
1099: }
1100:
1101:
1108: public void layoutContainer(Container pane)
1109: {
1110: super.layoutContainer(pane);
1111: int tabCount = tabPane.getTabCount();
1112: Point p = null;
1113: if (tabCount == 0)
1114: return;
1115: int tabPlacement = tabPane.getTabPlacement();
1116: incrButton.setVisible(false);
1117: decrButton.setVisible(false);
1118: if (tabPlacement == SwingConstants.TOP
1119: || tabPlacement == SwingConstants.BOTTOM)
1120: {
1121: if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x
1122: + rects[tabCount - 1].width)
1123: {
1124: Dimension incrDims = incrButton.getPreferredSize();
1125: Dimension decrDims = decrButton.getPreferredSize();
1126:
1127: decrButton.setBounds(tabAreaRect.x + tabAreaRect.width
1128: - incrDims.width - decrDims.width,
1129: tabAreaRect.y, decrDims.width,
1130: tabAreaRect.height);
1131: incrButton.setBounds(tabAreaRect.x + tabAreaRect.width
1132: - incrDims.width, tabAreaRect.y,
1133: decrDims.width, tabAreaRect.height);
1134:
1135: tabAreaRect.width -= decrDims.width + incrDims.width;
1136: incrButton.setVisible(true);
1137: decrButton.setVisible(true);
1138: }
1139: }
1140:
1141: if (tabPlacement == SwingConstants.LEFT
1142: || tabPlacement == SwingConstants.RIGHT)
1143: {
1144: if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y
1145: + rects[tabCount - 1].height)
1146: {
1147: Dimension incrDims = incrButton.getPreferredSize();
1148: Dimension decrDims = decrButton.getPreferredSize();
1149:
1150: decrButton.setBounds(tabAreaRect.x,
1151: tabAreaRect.y + tabAreaRect.height
1152: - incrDims.height - decrDims.height,
1153: tabAreaRect.width, decrDims.height);
1154: incrButton.setBounds(tabAreaRect.x,
1155: tabAreaRect.y + tabAreaRect.height
1156: - incrDims.height, tabAreaRect.width,
1157: incrDims.height);
1158:
1159: tabAreaRect.height -= decrDims.height + incrDims.height;
1160: incrButton.setVisible(true);
1161: decrButton.setVisible(true);
1162: }
1163: }
1164: viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width,
1165: tabAreaRect.height);
1166: int tabC = tabPane.getTabCount() - 1;
1167: if (tabCount > 0)
1168: {
1169: int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width);
1170: int h = Math.max(rects[tabC].height, tabAreaRect.height);
1171: p = findPointForIndex(currentScrollLocation);
1172:
1173:
1174:
1175: panel.setSize(w + p.x, h + p.y);
1176: }
1177: viewport.setViewPosition(p);
1178: viewport.repaint();
1179: }
1180: }
1181:
1182:
1189: public class TabSelectionHandler implements ChangeListener
1190: {
1191:
1197: public void stateChanged(ChangeEvent e)
1198: {
1199: selectedRun = getRunForTab(tabPane.getTabCount(),
1200: tabPane.getSelectedIndex());
1201: tabPane.revalidate();
1202: tabPane.repaint();
1203: }
1204: }
1205:
1206:
1211: private class ScrollingPanel extends JPanel
1212: {
1213:
1216: private class ScrollingPanelUI extends BasicPanelUI
1217: {
1218:
1225: public void paint(Graphics g, JComponent c)
1226: {
1227: paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
1228: }
1229: }
1230:
1231:
1235: public void updateUI()
1236: {
1237: setUI((PanelUI) new ScrollingPanelUI());
1238: }
1239: }
1240:
1241:
1247: private class ScrollingViewport extends JViewport implements UIResource
1248: {
1249:
1250: }
1251:
1252:
1256: private class ScrollingButton extends BasicArrowButton implements UIResource
1257: {
1258:
1263: public ScrollingButton(int dir)
1264: {
1265: super(dir);
1266: }
1267: }
1268:
1269:
1271: transient ScrollingButton incrButton;
1272:
1273:
1275: transient ScrollingButton decrButton;
1276:
1277:
1279: transient ScrollingViewport viewport;
1280:
1281:
1283: transient ScrollingPanel panel;
1284:
1285:
1287: transient int currentScrollLocation;
1288:
1289:
1290: protected Rectangle calcRect;
1291:
1292:
1293: protected Rectangle[] rects;
1294:
1295:
1296: protected Insets contentBorderInsets;
1297:
1298:
1299: protected Insets selectedTabPadInsets;
1300:
1301:
1302: protected Insets tabAreaInsets;
1303:
1304:
1305: protected Insets tabInsets;
1306:
1307:
1311: protected Color darkShadow;
1312:
1313:
1314: protected Color focus;
1315:
1316:
1317: protected Color highlight;
1318:
1319:
1320: protected Color lightHighlight;
1321:
1322:
1323: protected Color shadow;
1324:
1325:
1326: protected int maxTabHeight;
1327:
1328:
1329: protected int maxTabWidth;
1330:
1331:
1332: protected int runCount;
1333:
1334:
1335: protected int selectedRun;
1336:
1337:
1338: protected int tabRunOverlay;
1339:
1340:
1341: protected int textIconGap;
1342:
1343:
1344:
1345:
1346:
1347:
1348:
1349:
1350:
1351:
1352:
1353: protected int[] tabRuns;
1354:
1355:
1359: boolean tabRunsDirty;
1360:
1361:
1366: protected KeyStroke downKey;
1367:
1368:
1373: protected KeyStroke leftKey;
1374:
1375:
1380: protected KeyStroke rightKey;
1381:
1382:
1387: protected KeyStroke upKey;
1388:
1389:
1390: protected FocusListener focusListener;
1391:
1392:
1393: protected MouseListener mouseListener;
1394:
1395:
1396: protected PropertyChangeListener propertyChangeListener;
1397:
1398:
1399: protected ChangeListener tabChangeListener;
1400:
1401:
1402: protected JTabbedPane tabPane;
1403:
1404:
1406: transient LayoutManager layoutManager;
1407:
1408:
1410: transient Rectangle tabAreaRect;
1411:
1412:
1414: transient Rectangle contentRect;
1415:
1416:
1419: private int rolloverTab;
1420:
1421:
1425: private boolean tabsOpaque;
1426:
1427:
1430: private Component visibleComponent;
1431:
1432:
1435: public BasicTabbedPaneUI()
1436: {
1437: super();
1438: rects = new Rectangle[0];
1439: tabRuns = new int[10];
1440: }
1441:
1442:
1449: ScrollingButton createIncreaseButton()
1450: {
1451: if (incrButton == null)
1452: incrButton = new ScrollingButton(SwingConstants.NORTH);
1453: if (tabPane.getTabPlacement() == SwingConstants.TOP
1454: || tabPane.getTabPlacement() == SwingConstants.BOTTOM)
1455: incrButton.setDirection(SwingConstants.EAST);
1456: else
1457: incrButton.setDirection(SwingConstants.SOUTH);
1458: return incrButton;
1459: }
1460:
1461:
1468: ScrollingButton createDecreaseButton()
1469: {
1470: if (decrButton == null)
1471: decrButton = new ScrollingButton(SwingConstants.SOUTH);
1472: if (tabPane.getTabPlacement() == SwingConstants.TOP
1473: || tabPane.getTabPlacement() == SwingConstants.BOTTOM)
1474: decrButton.setDirection(SwingConstants.WEST);
1475: else
1476: decrButton.setDirection(SwingConstants.NORTH);
1477: return decrButton;
1478: }
1479:
1480:
1489: Point findPointForIndex(int index)
1490: {
1491: int tabPlacement = tabPane.getTabPlacement();
1492: int selectedIndex = tabPane.getSelectedIndex();
1493: Insets insets = getSelectedTabPadInsets(tabPlacement);
1494: int w = 0;
1495: int h = 0;
1496:
1497: if (tabPlacement == TOP || tabPlacement == BOTTOM)
1498: {
1499: if (index > 0)
1500: {
1501: w += rects[index - 1].x + rects[index - 1].width;
1502: if (index > selectedIndex)
1503: w -= insets.left + insets.right;
1504: }
1505: }
1506:
1507: else
1508: {
1509: if (index > 0)
1510: {
1511: h += rects[index - 1].y + rects[index - 1].height;
1512: if (index > selectedIndex)
1513: h -= insets.top + insets.bottom;
1514: }
1515: }
1516:
1517: Point p = new Point(w, h);
1518: return p;
1519: }
1520:
1521:
1528: public static ComponentUI createUI(JComponent c)
1529: {
1530: return new BasicTabbedPaneUI();
1531: }
1532:
1533:
1538: public void installUI(JComponent c)
1539: {
1540: super.installUI(c);
1541: if (c instanceof JTabbedPane)
1542: {
1543: tabPane = (JTabbedPane) c;
1544:
1545: installComponents();
1546: installDefaults();
1547: installListeners();
1548: installKeyboardActions();
1549:
1550: layoutManager = createLayoutManager();
1551: tabPane.setLayout(layoutManager);
1552: }
1553: }
1554:
1555:
1560: public void uninstallUI(JComponent c)
1561: {
1562: layoutManager = null;
1563:
1564: uninstallKeyboardActions();
1565: uninstallListeners();
1566: uninstallDefaults();
1567: uninstallComponents();
1568:
1569: tabPane = null;
1570: }
1571:
1572:
1580: protected LayoutManager createLayoutManager()
1581: {
1582: if (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT)
1583: return new TabbedPaneLayout();
1584: else
1585: {
1586: incrButton = createIncreaseButton();
1587: decrButton = createDecreaseButton();
1588: viewport = new ScrollingViewport();
1589: viewport.setLayout(null);
1590: panel = new ScrollingPanel();
1591: viewport.setView(panel);
1592: tabPane.add(incrButton);
1593: tabPane.add(decrButton);
1594: tabPane.add(viewport);
1595: currentScrollLocation = 0;
1596: decrButton.setEnabled(false);
1597: panel.addMouseListener(mouseListener);
1598: incrButton.addMouseListener(mouseListener);
1599: decrButton.addMouseListener(mouseListener);
1600: viewport.setBackground(Color.LIGHT_GRAY);
1601:
1602: return new TabbedPaneScrollLayout();
1603: }
1604: }
1605:
1606:
1609: protected void installComponents()
1610: {
1611:
1612: }
1613:
1614:
1617: protected void uninstallComponents()
1618: {
1619:
1620: }
1621:
1622:
1625: protected void installDefaults()
1626: {
1627: LookAndFeel.installColorsAndFont(tabPane, "TabbedPane.background",
1628: "TabbedPane.foreground",
1629: "TabbedPane.font");
1630: tabPane.setOpaque(false);
1631:
1632: highlight = UIManager.getColor("TabbedPane.highlight");
1633: lightHighlight = UIManager.getColor("TabbedPane.lightHighlight");
1634:
1635: shadow = UIManager.getColor("TabbedPane.shadow");
1636: darkShadow = UIManager.getColor("TabbedPane.darkShadow");
1637:
1638: focus = UIManager.getColor("TabbedPane.focus");
1639:
1640: textIconGap = UIManager.getInt("TabbedPane.textIconGap");
1641: tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay");
1642:
1643: tabInsets = UIManager.getInsets("TabbedPane.tabInsets");
1644: selectedTabPadInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabPadInsets");
1645: tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets");
1646: contentBorderInsets = UIManager.getInsets("TabbedPane.tabbedPaneContentBorderInsets");
1647: tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque");
1648:
1649: calcRect = new Rectangle();
1650: tabRuns = new int[10];
1651: tabAreaRect = new Rectangle();
1652: contentRect = new Rectangle();
1653: }
1654:
1655:
1658: protected void uninstallDefaults()
1659: {
1660: calcRect = null;
1661: tabAreaRect = null;
1662: contentRect = null;
1663: tabRuns = null;
1664:
1665: contentBorderInsets = null;
1666: tabAreaInsets = null;
1667: selectedTabPadInsets = null;
1668: tabInsets = null;
1669:
1670: focus = null;
1671: darkShadow = null;
1672: shadow = null;
1673: lightHighlight = null;
1674: highlight = null;
1675:
1676:
1677: LookAndFeel.installColorsAndFont(tabPane, "TabbedPane.background",
1678: "TabbedPane.foreground",
1679: "TabbedPane.font");
1680: }
1681:
1682:
1685: protected void installListeners()
1686: {
1687: mouseListener = createMouseListener();
1688: tabChangeListener = createChangeListener();
1689: propertyChangeListener = createPropertyChangeListener();
1690: focusListener = createFocusListener();
1691:
1692: tabPane.addMouseListener(mouseListener);
1693: tabPane.addChangeListener(tabChangeListener);
1694: tabPane.addPropertyChangeListener(propertyChangeListener);
1695: tabPane.addFocusListener(focusListener);
1696: }
1697:
1698:
1701: protected void uninstallListeners()
1702: {
1703: tabPane.removeFocusListener(focusListener);
1704: tabPane.removePropertyChangeListener(propertyChangeListener);
1705: tabPane.removeChangeListener(tabChangeListener);
1706: tabPane.removeMouseListener(mouseListener);
1707:
1708: focusListener = null;
1709: propertyChangeListener = null;
1710: tabChangeListener = null;
1711: mouseListener = null;
1712: }
1713:
1714:
1719: protected MouseListener createMouseListener()
1720: {
1721: return new MouseHandler();
1722: }
1723:
1724:
1729: protected FocusListener createFocusListener()
1730: {
1731: return new FocusHandler();
1732: }
1733:
1734:
1739: protected ChangeListener createChangeListener()
1740: {
1741: return new TabSelectionHandler();
1742: }
1743:
1744:
1749: protected PropertyChangeListener createPropertyChangeListener()
1750: {
1751: return new PropertyChangeHandler();
1752: }
1753:
1754:
1757: protected void installKeyboardActions()
1758: throws NotImplementedException
1759: {
1760:
1761: }
1762:
1763:
1766: protected void uninstallKeyboardActions()
1767: throws NotImplementedException
1768: {
1769:
1770: }
1771:
1772:
1779: public Dimension getMinimumSize(JComponent c)
1780: {
1781: return layoutManager.minimumLayoutSize(tabPane);
1782: }
1783:
1784:
1791: public Dimension getMaximumSize(JComponent c)
1792: {
1793: return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
1794: }
1795:
1796:
1802: public void paint(Graphics g, JComponent c)
1803: {
1804: if (!tabPane.isValid())
1805: tabPane.validate();
1806:
1807: if (tabPane.getTabCount() == 0)
1808: return;
1809: if (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT)
1810: paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
1811: paintContentBorder(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
1812: }
1813:
1814:
1822: protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex)
1823: {
1824: Rectangle ir = new Rectangle();
1825: Rectangle tr = new Rectangle();
1826:
1827: boolean isScroll = tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT;
1828:
1829:
1830:
1831: int tabCount = tabPane.getTabCount();
1832: for (int i = runCount - 1; i >= 0; --i)
1833: {
1834: int start = tabRuns[i];
1835: int next;
1836: if (i == runCount - 1)
1837: next = tabRuns[0];
1838: else
1839: next = tabRuns[i + 1];
1840: int end = next != 0 ? next - 1 : tabCount - 1;
1841: for (int j = start; j <= end; ++j)
1842: {
1843: if (j != selectedIndex)
1844: {
1845: paintTab(g, tabPlacement, rects, j, ir, tr);
1846: }
1847: }
1848: }
1849:
1850:
1851: if (selectedIndex >= 0)
1852: paintTab(g, tabPlacement, rects, selectedIndex, ir, tr);
1853: }
1854:
1855:
1866: protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects,
1867: int tabIndex, Rectangle iconRect, Rectangle textRect)
1868: {
1869: Rectangle rect = rects[tabIndex];
1870: boolean isSelected = tabIndex == tabPane.getSelectedIndex();
1871:
1872: if (tabsOpaque || tabPane.isOpaque())
1873: {
1874: paintTabBackground(g, tabPlacement, tabIndex, rect.x, rect.y,
1875: rect.width, rect.height, isSelected);
1876: }
1877:
1878:
1879: paintTabBorder(g, tabPlacement, tabIndex, rect.x, rect.y, rect.width,
1880: rect.height, isSelected);
1881:
1882:
1883:
1884: FontMetrics fm = getFontMetrics();
1885: Icon icon = getIconForTab(tabIndex);
1886: String title = tabPane.getTitleAt(tabIndex);
1887: layoutLabel(tabPlacement, fm, tabIndex, title, icon, rect, iconRect,
1888: textRect, isSelected);
1889:
1890: paintText(g, tabPlacement, tabPane.getFont(), fm, tabIndex, title,
1891: textRect, isSelected);
1892:
1893: paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
1894:
1895: paintFocusIndicator(g, tabPlacement, rects, tabIndex, iconRect, textRect,
1896: isSelected);
1897: }
1898:
1899:
1913: protected void layoutLabel(int tabPlacement, FontMetrics metrics,
1914: int tabIndex, String title, Icon icon,
1915: Rectangle tabRect, Rectangle iconRect,
1916: Rectangle textRect, boolean isSelected)
1917: {
1918: SwingUtilities.layoutCompoundLabel(metrics, title, icon,
1919: SwingConstants.CENTER,
1920: SwingConstants.CENTER,
1921: SwingConstants.CENTER,
1922: SwingConstants.RIGHT, tabRect,
1923: iconRect, textRect, textIconGap);
1924:
1925: int shiftX = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);
1926: int shiftY = getTabLabelShiftY(tabPlacement, tabIndex, isSelected);
1927:
1928: iconRect.x += shiftX;
1929: iconRect.y += shiftY;
1930:
1931: textRect.x += shiftX;
1932: textRect.y += shiftY;
1933: }
1934:
1935:
1945: protected void paintIcon(Graphics g, int tabPlacement, int tabIndex,
1946: Icon icon, Rectangle iconRect, boolean isSelected)
1947: {
1948: if (icon != null)
1949: icon.paintIcon(tabPane, g, iconRect.x, iconRect.y);
1950: }
1951:
1952:
1964: protected void paintText(Graphics g, int tabPlacement, Font font,
1965: FontMetrics metrics, int tabIndex, String title,
1966: Rectangle textRect, boolean isSelected)
1967: {
1968: g.setFont(font);
1969: View textView = getTextViewForTab(tabIndex);
1970: if (textView != null)
1971: {
1972: textView.paint(g, textRect);
1973: return;
1974: }
1975:
1976: int ascent = metrics.getAscent();
1977:
1978: int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
1979: if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex))
1980: {
1981: Color fg = tabPane.getForegroundAt(tabIndex);
1982: if (isSelected && (fg instanceof UIResource))
1983: {
1984: Color selectionForeground =
1985: UIManager.getColor("TabbedPane.selectionForeground");
1986: if (selectionForeground != null)
1987: fg = selectionForeground;
1988: }
1989: g.setColor(fg);
1990:
1991: if (mnemIndex != -1)
1992: BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,
1993: textRect.x,
1994: textRect.y + ascent);
1995: else
1996: g.drawString(title, textRect.x, textRect.y + ascent);
1997: }
1998: else
1999: {
2000: Color bg = tabPane.getBackgroundAt(tabIndex);
2001: g.setColor(bg.brighter());
2002: if (mnemIndex != -1)
2003: BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,
2004: textRect.x, textRect.y
2005: + ascent);
2006: else
2007: g.drawString(title, textRect.x, textRect.y + ascent);
2008:
2009: g.setColor(bg.darker());
2010: if (mnemIndex != -1)
2011: BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,
2012: textRect.x + 1,
2013: textRect.y + 1
2014: + ascent);
2015: else
2016: g.drawString(title, textRect.x + 1, textRect.y + 1 + ascent);
2017: }
2018: }
2019:
2020:
2030: protected int getTabLabelShiftX(int tabPlacement, int tabIndex,
2031: boolean isSelected)
2032: {
2033:
2034: return 0;
2035: }
2036:
2037:
2047: protected int getTabLabelShiftY(int tabPlacement, int tabIndex,
2048: boolean isSelected)
2049: {
2050:
2051: return 0;
2052: }
2053:
2054:
2065: protected void paintFocusIndicator(Graphics g, int tabPlacement,
2066: Rectangle[] rects, int tabIndex,
2067: Rectangle iconRect, Rectangle textRect,
2068: boolean isSelected)
2069: {
2070: if (tabPane.hasFocus() && isSelected)
2071: {
2072: Rectangle rect = rects[tabIndex];
2073:
2074: int x;
2075: int y;
2076: int w;
2077: int h;
2078:
2079: g.setColor(focus);
2080: switch (tabPlacement)
2081: {
2082: case LEFT:
2083: x = rect.x + 3;
2084: y = rect.y + 3;
2085: w = rect.width - 5;
2086: h = rect.height - 6;
2087: break;
2088: case RIGHT:
2089: x = rect.x + 2;
2090: y = rect.y + 3;
2091: w = rect.width - 6;
2092: h = rect.height - 5;
2093: break;
2094: case BOTTOM:
2095: x = rect.x + 3;
2096: y = rect.y + 2;
2097: w = rect.width - 6;
2098: h = rect.height - 5;
2099: break;
2100: case TOP:
2101: default:
2102: x = rect.x + 3;
2103: y = rect.y + 3;
2104: w = rect.width - 6;
2105: h = rect.height - 5;
2106: }
2107: BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
2108: }
2109: }
2110:
2111:
2123: protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
2124: int x, int y, int w, int h, boolean isSelected)
2125: {
2126: Color saved = g.getColor();
2127:
2128: if (! isSelected || tabPlacement != SwingConstants.TOP)
2129: {
2130: g.setColor(shadow);
2131: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
2132: g.setColor(darkShadow);
2133: g.drawLine(x, y + h, x + w, y + h);
2134: }
2135:
2136: if (! isSelected || tabPlacement != SwingConstants.LEFT)
2137: {
2138: g.setColor(darkShadow);
2139: g.drawLine(x + w, y, x + w, y + h);
2140: g.setColor(shadow);
2141: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
2142: }
2143:
2144: if (! isSelected || tabPlacement != SwingConstants.RIGHT)
2145: {
2146: g.setColor(lightHighlight);
2147: g.drawLine(x, y, x, y + h);
2148: }
2149:
2150: if (! isSelected || tabPlacement != SwingConstants.BOTTOM)
2151: {
2152: g.setColor(lightHighlight);
2153: g.drawLine(x, y, x + w, y);
2154: }
2155:
2156: g.setColor(saved);
2157: }
2158:
2159:
2171: protected void paintTabBackground(Graphics g, int tabPlacement,
2172: int tabIndex, int x, int y, int w, int h,
2173: boolean isSelected)
2174: {
2175: Color saved = g.getColor();
2176: if (isSelected)
2177: g.setColor(Color.LIGHT_GRAY);
2178: else
2179: {
2180: Color bg = tabPane.getBackgroundAt(tabIndex);
2181: if (bg == null)
2182: bg = Color.GRAY;
2183: g.setColor(bg);
2184: }
2185:
2186: g.fillRect(x, y, w, h);
2187:
2188: g.setColor(saved);
2189: }
2190:
2191:
2198: protected void paintContentBorder(Graphics g, int tabPlacement,
2199: int selectedIndex)
2200: {
2201: int width = tabPane.getWidth();
2202: int height = tabPane.getHeight();
2203: Insets insets = tabPane.getInsets();
2204: Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
2205:
2206:
2207: int x = insets.left;
2208: int y = insets.top;
2209: int w = width - insets.left - insets.right;
2210: int h = height - insets.top - insets.bottom;
2211:
2212: switch (tabPlacement)
2213: {
2214: case LEFT:
2215: x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
2216: w -= x - insets.left;
2217: break;
2218: case RIGHT:
2219: w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
2220: break;
2221: case BOTTOM:
2222: h -= calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
2223: break;
2224: case TOP:
2225: default:
2226: y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
2227: h -= y - insets.top;
2228: }
2229:
2230:
2231: if (tabPane.isOpaque())
2232: {
2233: Color bg = UIManager.getColor("TabbedPane.contentAreaColor");
2234: g.setColor(bg);
2235: g.fillRect(x, y, w, h);
2236: }
2237:
2238:
2239: paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h);
2240: paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h);
2241: paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h);
2242: paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h);
2243: }
2244:
2245:
2256: protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
2257: int selectedIndex, int x, int y,
2258: int w, int h)
2259: {
2260: Color saved = g.getColor();
2261: g.setColor(lightHighlight);
2262:
2263: int startgap = rects[selectedIndex].x;
2264: int endgap = rects[selectedIndex].x + rects[selectedIndex].width;
2265:
2266: int diff = 0;
2267:
2268: if (tabPlacement == SwingConstants.TOP)
2269: {
2270: if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
2271: {
2272: Point p = findPointForIndex(currentScrollLocation);
2273: diff = p.x;
2274: }
2275:
2276: g.drawLine(x, y, startgap - diff, y);
2277: g.drawLine(endgap - diff, y, x + w, y);
2278: }
2279: else
2280: g.drawLine(x, y, x + w, y);
2281:
2282: g.setColor(saved);
2283: }
2284:
2285:
2296: protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
2297: int selectedIndex, int x, int y,
2298: int w, int h)
2299: {
2300: Color saved = g.getColor();
2301: g.setColor(lightHighlight);
2302:
2303: int startgap = rects[selectedIndex].y;
2304: int endgap = rects[selectedIndex].y + rects[selectedIndex].height;
2305:
2306: int diff = 0;
2307:
2308: if (tabPlacement == SwingConstants.LEFT)
2309: {
2310: if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
2311: {
2312: Point p = findPointForIndex(currentScrollLocation);
2313: diff = p.y;
2314: }
2315:
2316: g.drawLine(x, y, x, startgap - diff);
2317: g.drawLine(x, endgap - diff, x, y + h);
2318: }
2319: else
2320: g.drawLine(x, y, x, y + h);
2321:
2322: g.setColor(saved);
2323: }
2324:
2325:
2336: protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
2337: int selectedIndex, int x, int y,
2338: int w, int h)
2339: {
2340: Color saved = g.getColor();
2341:
2342: int startgap = rects[selectedIndex].x;
2343: int endgap = rects[selectedIndex].x + rects[selectedIndex].width;
2344:
2345: int diff = 0;
2346:
2347: if (tabPlacement == SwingConstants.BOTTOM)
2348: {
2349: if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
2350: {
2351: Point p = findPointForIndex(currentScrollLocation);
2352: diff = p.x;
2353: }
2354:
2355: g.setColor(shadow);
2356: g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1);
2357: g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1);
2358:
2359: g.setColor(darkShadow);
2360: g.drawLine(x, y + h, startgap - diff, y + h);
2361: g.drawLine(endgap - diff, y + h, x + w, y + h);
2362: }
2363: else
2364: {
2365: g.setColor(shadow);
2366: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
2367: g.setColor(darkShadow);
2368: g.drawLine(x, y + h, x + w, y + h);
2369: }
2370:
2371: g.setColor(saved);
2372: }
2373:
2374:
2385: protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
2386: int selectedIndex, int x, int y,
2387: int w, int h)
2388: {
2389: Color saved = g.getColor();
2390: int startgap = rects[selectedIndex].y;
2391: int endgap = rects[selectedIndex].y + rects[selectedIndex].height;
2392:
2393: int diff = 0;
2394:
2395: if (tabPlacement == SwingConstants.RIGHT)
2396: {
2397: if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
2398: {
2399: Point p = findPointForIndex(currentScrollLocation);
2400: diff = p.y;
2401: }
2402:
2403: g.setColor(shadow);
2404: g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff);
2405: g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1);
2406:
2407: g.setColor(darkShadow);
2408: g.drawLine(x + w, y, x + w, startgap - diff);
2409: g.drawLine(x + w, endgap - diff, x + w, y + h);
2410: }
2411: else
2412: {
2413: g.setColor(shadow);
2414: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
2415: g.setColor(darkShadow);
2416: g.drawLine(x + w, y, x + w, y + h);
2417: }
2418:
2419: g.setColor(saved);
2420: }
2421:
2422:
2430: public Rectangle getTabBounds(JTabbedPane pane, int i)
2431: {
2432:
2433: if (i >= rects.length)
2434: layoutManager.layoutContainer(pane);
2435: return rects[i];
2436: }
2437:
2438:
2445: public int getTabRunCount(JTabbedPane pane)
2446: {
2447: return runCount;
2448: }
2449:
2450:
2459: public int tabForCoordinate(JTabbedPane pane, int x, int y)
2460: {
2461: if (! tabPane.isValid())
2462: tabPane.validate();
2463:
2464: int tabCount = tabPane.getTabCount();
2465: int index = -1;
2466: for (int i = 0; i < tabCount; ++i)
2467: {
2468: if (rects[i].contains(x, y))
2469: {
2470: index = i;
2471: break;
2472: }
2473: }
2474:
2475:
2476:
2477: return index;
2478: }
2479:
2480:
2488: protected Rectangle getTabBounds(int tabIndex, Rectangle dest)
2489: {
2490: dest.setBounds(getTabBounds(tabPane, tabIndex));
2491: return dest;
2492: }
2493:
2494:
2499: protected Component getVisibleComponent()
2500: {
2501: return visibleComponent;
2502: }
2503:
2504:
2509: protected void setVisibleComponent(Component component)
2510: {
2511:
2512: if (visibleComponent != null && visibleComponent != component
2513: && visibleComponent.getParent() == tabPane)
2514: {
2515: visibleComponent.setVisible(false);
2516: }
2517:
2518:
2519: if (component != null && ! component.isVisible())
2520: {
2521: component.setVisible(true);
2522: }
2523: visibleComponent = component;
2524: }
2525:
2526:
2532: protected void assureRectsCreated(int tabCount)
2533: {
2534: if (rects.length < tabCount)
2535: {
2536: Rectangle[] old = rects;
2537: rects = new Rectangle[tabCount];
2538: System.arraycopy(old, 0, rects, 0, old.length);
2539: for (int i = old.length; i < rects.length; i++)
2540: rects[i] = new Rectangle();
2541: }
2542: }
2543:
2544:
2548: protected void expandTabRunsArray()
2549: {
2550:
2551: if (tabRuns == null)
2552: tabRuns = new int[10];
2553: else
2554: {
2555: int[] newRuns = new int[tabRuns.length + 10];
2556: System.arraycopy(tabRuns, 0, newRuns, 0, tabRuns.length);
2557: tabRuns = newRuns;
2558: }
2559: }
2560:
2561:
2569: protected int getRunForTab(int tabCount, int tabIndex)
2570: {
2571: if (runCount == 1 && tabIndex < tabCount && tabIndex >= 0)
2572: return 1;
2573: for (int i = 0; i < runCount; i++)
2574: {
2575: int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1;
2576: if (first == tabCount)
2577: first = 0;
2578: int last = lastTabInRun(tabCount, i);
2579: if (last >= tabIndex && first <= tabIndex)
2580: return i;
2581: }
2582: return -1;
2583: }
2584:
2585:
2593: protected int lastTabInRun(int tabCount, int run)
2594: {
2595: int lastTab;
2596: if (runCount == 1)
2597: lastTab = tabCount - 1;
2598: else
2599: {
2600: int nextRun;
2601: if (run == runCount - 1)
2602: nextRun = 0;
2603: else
2604: nextRun = run + 1;
2605:
2606: if (tabRuns[nextRun] == 0)
2607: lastTab = tabCount - 1;
2608: else
2609: lastTab = tabRuns[nextRun] - 1;
2610: }
2611: return lastTab;
2612: }
2613:
2614:
2621: protected int getTabRunOverlay(int tabPlacement)
2622: {
2623: return tabRunOverlay;
2624: }
2625:
2626:
2635: protected int getTabRunIndent(int tabPlacement, int run)
2636: {
2637: return 0;
2638: }
2639:
2640:
2648: protected boolean shouldPadTabRun(int tabPlacement, int run)
2649: {
2650: return true;
2651: }
2652:
2653:
2660: protected boolean shouldRotateTabRuns(int tabPlacement)
2661: {
2662: return true;
2663: }
2664:
2665:
2674: protected Icon getIconForTab(int tabIndex)
2675: {
2676: if (tabPane.isEnabledAt(tabIndex))
2677: return tabPane.getIconAt(tabIndex);
2678: else
2679: return tabPane.getDisabledIconAt(tabIndex);
2680: }
2681:
2682:
2689: protected View getTextViewForTab(int tabIndex)
2690: {
2691: return null;
2692: }
2693:
2694:
2704: protected int calculateTabHeight(int tabPlacement, int tabIndex,
2705: int fontHeight)
2706: {
2707:
2708:
2709: int height = fontHeight;
2710: Icon icon = getIconForTab(tabIndex);
2711: Insets tabInsets = getTabInsets(tabPlacement, tabIndex);
2712: if (icon != null)
2713: height = Math.max(height, icon.getIconHeight());
2714: height += tabInsets.top + tabInsets.bottom + 2;
2715: return height;
2716: }
2717:
2718:
2725: protected int calculateMaxTabHeight(int tabPlacement)
2726: {
2727: maxTabHeight = 0;
2728:
2729: FontMetrics fm = getFontMetrics();
2730: int fontHeight = fm.getHeight();
2731:
2732: for (int i = 0; i < tabPane.getTabCount(); i++)
2733: maxTabHeight = Math.max(calculateTabHeight(tabPlacement, i, fontHeight),
2734: maxTabHeight);
2735:
2736: return maxTabHeight;
2737: }
2738:
2739:
2749: protected int calculateTabWidth(int tabPlacement, int tabIndex,
2750: FontMetrics metrics)
2751: {
2752: Icon icon = getIconForTab(tabIndex);
2753: Insets insets = getTabInsets(tabPlacement, tabIndex);
2754:
2755: int width = 0;
2756: if (icon != null)
2757: {
2758: Rectangle vr = new Rectangle();
2759: Rectangle ir = new Rectangle();
2760: Rectangle tr = new Rectangle();
2761: layoutLabel(tabPlacement, getFontMetrics(), tabIndex,
2762: tabPane.getTitleAt(tabIndex), icon, vr, ir, tr,
2763: tabIndex == tabPane.getSelectedIndex());
2764: width = tr.union(ir).width;
2765: }
2766: else
2767: width = metrics.stringWidth(tabPane.getTitleAt(tabIndex));
2768:
2769: width += insets.left + insets.right;
2770: return width;
2771: }
2772:
2773:
2780: protected int calculateMaxTabWidth(int tabPlacement)
2781: {
2782: maxTabWidth = 0;
2783:
2784: FontMetrics fm = getFontMetrics();
2785:
2786: for (int i = 0; i < tabPane.getTabCount(); i++)
2787: maxTabWidth = Math.max(calculateTabWidth(tabPlacement, i, fm),
2788: maxTabWidth);
2789:
2790: return maxTabWidth;
2791: }
2792:
2793:
2803: protected int calculateTabAreaHeight(int tabPlacement, int horizRunCount,
2804: int maxTabHeight)
2805: {
2806: Insets insets = getTabAreaInsets(tabPlacement);
2807: int tabAreaHeight = horizRunCount * maxTabHeight
2808: - (horizRunCount - 1) * tabRunOverlay;
2809:
2810: tabAreaHeight += insets.top + insets.bottom;
2811:
2812: return tabAreaHeight;
2813: }
2814:
2815:
2825: protected int calculateTabAreaWidth(int tabPlacement, int vertRunCount,
2826: int maxTabWidth)
2827: {
2828: Insets insets = getTabAreaInsets(tabPlacement);
2829: int tabAreaWidth = vertRunCount * maxTabWidth
2830: - (vertRunCount - 1) * tabRunOverlay;
2831:
2832: tabAreaWidth += insets.left + insets.right;
2833:
2834: return tabAreaWidth;
2835: }
2836:
2837:
2845: protected Insets getTabInsets(int tabPlacement, int tabIndex)
2846: {
2847: return tabInsets;
2848: }
2849:
2850:
2857: protected Insets getSelectedTabPadInsets(int tabPlacement)
2858: {
2859: Insets target = new Insets(0, 0, 0, 0);
2860: rotateInsets(selectedTabPadInsets, target, tabPlacement);
2861: return target;
2862: }
2863:
2864:
2871: protected Insets getTabAreaInsets(int tabPlacement)
2872: {
2873: Insets target = new Insets(0, 0, 0, 0);
2874: rotateInsets(tabAreaInsets, target, tabPlacement);
2875: return target;
2876: }
2877:
2878:
2885: protected Insets getContentBorderInsets(int tabPlacement)
2886: {
2887: Insets target = new Insets(0, 0, 0, 0);
2888: rotateInsets(contentBorderInsets, target, tabPlacement);
2889: return target;
2890: }
2891:
2892:
2897: protected FontMetrics getFontMetrics()
2898: {
2899: FontMetrics fm = tabPane.getFontMetrics(tabPane.getFont());
2900: return fm;
2901: }
2902:
2903:
2909: protected void navigateSelectedTab(int direction)
2910: {
2911: int tabPlacement = tabPane.getTabPlacement();
2912: if (tabPlacement == SwingConstants.TOP
2913: || tabPlacement == SwingConstants.BOTTOM)
2914: {
2915: if (direction == SwingConstants.WEST)
2916: selectPreviousTabInRun(tabPane.getSelectedIndex());
2917: else if (direction == SwingConstants.EAST)
2918: selectNextTabInRun(tabPane.getSelectedIndex());
2919:
2920: else
2921: {
2922: int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(),
2923: tabPane.getSelectedIndex(),
2924: (tabPlacement == SwingConstants.RIGHT)
2925: ? true : false);
2926: selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(),
2927: offset);
2928: }
2929: }
2930: if (tabPlacement == SwingConstants.LEFT
2931: || tabPlacement == SwingConstants.RIGHT)
2932: {
2933: if (direction == SwingConstants.NORTH)
2934: selectPreviousTabInRun(tabPane.getSelectedIndex());
2935: else if (direction == SwingConstants.SOUTH)
2936: selectNextTabInRun(tabPane.getSelectedIndex());
2937: else
2938: {
2939: int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(),
2940: tabPane.getSelectedIndex(),
2941: (tabPlacement == SwingConstants.RIGHT)
2942: ? true : false);
2943: selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(),
2944: offset);
2945: }
2946: }
2947: }
2948:
2949:
2954: protected void selectNextTabInRun(int current)
2955: {
2956: tabPane.setSelectedIndex(getNextTabIndexInRun(tabPane.getTabCount(),
2957: current));
2958: }
2959:
2960:
2965: protected void selectPreviousTabInRun(int current)
2966: {
2967: tabPane.setSelectedIndex(getPreviousTabIndexInRun(tabPane.getTabCount(),
2968: current));
2969: }
2970:
2971:
2976: protected void selectNextTab(int current)
2977: {
2978: tabPane.setSelectedIndex(getNextTabIndex(current));
2979: }
2980:
2981:
2986: protected void selectPreviousTab(int current)
2987: {
2988: tabPane.setSelectedIndex(getPreviousTabIndex(current));
2989: }
2990:
2991:
3002: protected void selectAdjacentRunTab(int tabPlacement, int tabIndex,
3003: int offset)
3004: {
3005: int x = rects[tabIndex].x + rects[tabIndex].width / 2;
3006: int y = rects[tabIndex].y + rects[tabIndex].height / 2;
3007:
3008: switch (tabPlacement)
3009: {
3010: case SwingConstants.TOP:
3011: case SwingConstants.BOTTOM:
3012: y += offset;
3013: break;
3014: case SwingConstants.RIGHT:
3015: case SwingConstants.LEFT:
3016: x += offset;
3017: break;
3018: }
3019:
3020: int index = tabForCoordinate(tabPane, x, y);
3021: if (index != -1)
3022: tabPane.setSelectedIndex(index);
3023: }
3024:
3025:
3026:
3027:
3028:
3029:
3030:
3031:
3046: protected int getTabRunOffset(int tabPlacement, int tabCount, int tabIndex,
3047: boolean forward)
3048: {
3049: int currRun = getRunForTab(tabCount, tabIndex);
3050: int offset;
3051: int nextRun = forward ? getNextTabRun(currRun) : getPreviousTabRun(currRun);
3052: if (tabPlacement == SwingConstants.TOP
3053: || tabPlacement == SwingConstants.BOTTOM)
3054: offset = rects[lastTabInRun(tabCount, nextRun)].y
3055: - rects[lastTabInRun(tabCount, currRun)].y;
3056: else
3057: offset = rects[lastTabInRun(tabCount, nextRun)].x
3058: - rects[lastTabInRun(tabCount, currRun)].x;
3059: return offset;
3060: }
3061:
3062:
3069: protected int getPreviousTabIndex(int base)
3070: {
3071: base--;
3072: if (base < 0)
3073: return tabPane.getTabCount() - 1;
3074: return base;
3075: }
3076:
3077:
3084: protected int getNextTabIndex(int base)
3085: {
3086: base++;
3087: if (base == tabPane.getTabCount())
3088: return 0;
3089: return base;
3090: }
3091:
3092:
3101: protected int getNextTabIndexInRun(int tabCount, int base)
3102: {
3103: int index = getNextTabIndex(base);
3104: int run = getRunForTab(tabCount, base);
3105: if (index == lastTabInRun(tabCount, run) + 1)
3106: index = lastTabInRun(tabCount, getPreviousTabRun(run)) + 1;
3107: return getNextTabIndex(base);
3108: }
3109:
3110:
3119: protected int getPreviousTabIndexInRun(int tabCount, int base)
3120: {
3121: int index = getPreviousTabIndex(base);
3122: int run = getRunForTab(tabCount, base);
3123: if (index == lastTabInRun(tabCount, getPreviousTabRun(run)))
3124: index = lastTabInRun(tabCount, run);
3125: return getPreviousTabIndex(base);
3126: }
3127:
3128:
3135: protected int getPreviousTabRun(int baseRun)
3136: {
3137: if (getTabRunCount(tabPane) == 1)
3138: return 1;
3139:
3140: int prevRun = --baseRun;
3141: if (prevRun < 0)
3142: prevRun = getTabRunCount(tabPane) - 1;
3143: return prevRun;
3144: }
3145:
3146:
3153: protected int getNextTabRun(int baseRun)
3154: {
3155: if (getTabRunCount(tabPane) == 1)
3156: return 1;
3157:
3158: int nextRun = ++baseRun;
3159: if (nextRun == getTabRunCount(tabPane))
3160: nextRun = 0;
3161: return nextRun;
3162: }
3163:
3164:
3176: protected static void rotateInsets(Insets topInsets, Insets targetInsets,
3177: int targetPlacement)
3178: {
3179:
3180:
3181: switch (targetPlacement)
3182: {
3183: case SwingConstants.TOP:
3184: targetInsets.top = topInsets.top;
3185: targetInsets.left = topInsets.left;
3186: targetInsets.right = topInsets.right;
3187: targetInsets.bottom = topInsets.bottom;
3188: break;
3189: case SwingConstants.LEFT:
3190: targetInsets.left = topInsets.top;
3191: targetInsets.top = topInsets.left;
3192: targetInsets.right = topInsets.bottom;
3193: targetInsets.bottom = topInsets.right;
3194: break;
3195: case SwingConstants.BOTTOM:
3196: targetInsets.top = topInsets.bottom;
3197: targetInsets.bottom = topInsets.top;
3198: targetInsets.left = topInsets.left;
3199: targetInsets.right = topInsets.right;
3200: break;
3201: case SwingConstants.RIGHT:
3202: targetInsets.top = topInsets.left;
3203: targetInsets.left = topInsets.bottom;
3204: targetInsets.bottom = topInsets.right;
3205: targetInsets.right = topInsets.top;
3206: break;
3207: }
3208: }
3209:
3210:
3220: protected void setRolloverTab(int index)
3221: {
3222: rolloverTab = index;
3223: }
3224:
3225:
3234: protected int getRolloverTab()
3235: {
3236: return rolloverTab;
3237: }
3238: }