208 |
incrButton = createIncreaseButton(); |
incrButton = createIncreaseButton(); |
209 |
decrButton = createDecreaseButton(); |
decrButton = createDecreaseButton(); |
210 |
} |
} |
211 |
tabPane.layout(); |
tabPane.revalidate(); |
212 |
tabPane.repaint(); |
tabPane.repaint(); |
213 |
} |
} |
214 |
} |
} |
241 |
*/ |
*/ |
242 |
public void calculateLayoutInfo() |
public void calculateLayoutInfo() |
243 |
{ |
{ |
244 |
|
assureRectsCreated(tabPane.getTabCount()); |
245 |
|
contentRect = SwingUtilities.calculateInnerArea(tabPane, contentRect); |
246 |
|
|
247 |
calculateTabRects(tabPane.getTabPlacement(), tabPane.getTabCount()); |
calculateTabRects(tabPane.getTabPlacement(), tabPane.getTabCount()); |
248 |
|
|
249 |
if (tabPane.getSelectedIndex() != -1) |
if (tabPane.getSelectedIndex() != -1) |
289 |
componentWidth = Math.max(componentWidth, dims.width); |
componentWidth = Math.max(componentWidth, dims.width); |
290 |
} |
} |
291 |
} |
} |
|
Insets insets = tabPane.getInsets(); |
|
|
|
|
292 |
if (tabPlacement == SwingConstants.TOP |
if (tabPlacement == SwingConstants.TOP |
293 |
|| tabPlacement == SwingConstants.BOTTOM) |
|| tabPlacement == SwingConstants.BOTTOM) |
294 |
{ |
{ |
332 |
{ |
{ |
333 |
if (tabCount == 0) |
if (tabCount == 0) |
334 |
return; |
return; |
|
assureRectsCreated(tabCount); |
|
335 |
|
|
336 |
FontMetrics fm = getFontMetrics(); |
FontMetrics fm = getFontMetrics(); |
337 |
SwingUtilities.calculateInnerArea(tabPane, calcRect); |
SwingUtilities.calculateInnerArea(tabPane, calcRect); |
944 |
{ |
{ |
945 |
if (tabCount == 0) |
if (tabCount == 0) |
946 |
return; |
return; |
|
assureRectsCreated(tabCount); |
|
947 |
|
|
948 |
FontMetrics fm = getFontMetrics(); |
FontMetrics fm = getFontMetrics(); |
949 |
SwingUtilities.calculateInnerArea(tabPane, calcRect); |
SwingUtilities.calculateInnerArea(tabPane, calcRect); |
950 |
Insets tabAreaInsets = getTabAreaInsets(tabPlacement); |
Insets tabAreaInsets = getTabAreaInsets(tabPlacement); |
951 |
Insets insets = tabPane.getInsets(); |
Insets insets = tabPane.getInsets(); |
|
int max = 0; |
|
952 |
int runs = 1; |
int runs = 1; |
953 |
int start = 0; |
int start = 0; |
954 |
int top = 0; |
int top = 0; |
957 |
{ |
{ |
958 |
int maxHeight = calculateMaxTabHeight(tabPlacement); |
int maxHeight = calculateMaxTabHeight(tabPlacement); |
959 |
calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; |
calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; |
|
max = calcRect.width + tabAreaInsets.left + insets.left; |
|
960 |
start = tabAreaInsets.left + insets.left; |
start = tabAreaInsets.left + insets.left; |
961 |
int width = 0; |
int width = 0; |
962 |
int runWidth = start; |
int runWidth = start; |
993 |
int maxWidth = calculateMaxTabWidth(tabPlacement); |
int maxWidth = calculateMaxTabWidth(tabPlacement); |
994 |
|
|
995 |
calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; |
calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; |
|
max = calcRect.height + tabAreaInsets.top; |
|
996 |
int height = 0; |
int height = 0; |
997 |
start = tabAreaInsets.top + insets.top; |
start = tabAreaInsets.top + insets.top; |
998 |
int runHeight = start; |
int runHeight = start; |
1044 |
if (tabCount == 0) |
if (tabCount == 0) |
1045 |
return; |
return; |
1046 |
int tabPlacement = tabPane.getTabPlacement(); |
int tabPlacement = tabPane.getTabPlacement(); |
1047 |
incrButton.hide(); |
incrButton.setVisible(false); |
1048 |
decrButton.hide(); |
decrButton.setVisible(false); |
1049 |
if (tabPlacement == SwingConstants.TOP |
if (tabPlacement == SwingConstants.TOP |
1050 |
|| tabPlacement == SwingConstants.BOTTOM) |
|| tabPlacement == SwingConstants.BOTTOM) |
1051 |
{ |
{ |
1064 |
decrDims.width, tabAreaRect.height); |
decrDims.width, tabAreaRect.height); |
1065 |
|
|
1066 |
tabAreaRect.width -= decrDims.width + incrDims.width; |
tabAreaRect.width -= decrDims.width + incrDims.width; |
1067 |
incrButton.show(); |
incrButton.setVisible(true); |
1068 |
decrButton.show(); |
decrButton.setVisible(true); |
1069 |
} |
} |
1070 |
} |
} |
1071 |
|
|
1088 |
incrDims.height); |
incrDims.height); |
1089 |
|
|
1090 |
tabAreaRect.height -= decrDims.height + incrDims.height; |
tabAreaRect.height -= decrDims.height + incrDims.height; |
1091 |
incrButton.show(); |
incrButton.setVisible(true); |
1092 |
decrButton.show(); |
decrButton.setVisible(true); |
1093 |
} |
} |
1094 |
} |
} |
1095 |
viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, |
viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, |
1344 |
public BasicTabbedPaneUI() |
public BasicTabbedPaneUI() |
1345 |
{ |
{ |
1346 |
super(); |
super(); |
1347 |
|
rects = new Rectangle[0]; |
1348 |
|
tabRuns = new int[10]; |
1349 |
} |
} |
1350 |
|
|
1351 |
/** |
/** |
1458 |
|
|
1459 |
layoutManager = createLayoutManager(); |
layoutManager = createLayoutManager(); |
1460 |
tabPane.setLayout(layoutManager); |
tabPane.setLayout(layoutManager); |
|
tabPane.layout(); |
|
1461 |
} |
} |
1462 |
} |
} |
1463 |
|
|
2107 |
protected void paintContentBorder(Graphics g, int tabPlacement, |
protected void paintContentBorder(Graphics g, int tabPlacement, |
2108 |
int selectedIndex) |
int selectedIndex) |
2109 |
{ |
{ |
|
Insets insets = getContentBorderInsets(tabPlacement); |
|
2110 |
int x = contentRect.x; |
int x = contentRect.x; |
2111 |
int y = contentRect.y; |
int y = contentRect.y; |
2112 |
int w = contentRect.width; |
int w = contentRect.width; |
2392 |
*/ |
*/ |
2393 |
protected void assureRectsCreated(int tabCount) |
protected void assureRectsCreated(int tabCount) |
2394 |
{ |
{ |
2395 |
if (rects == null) |
if (rects.length < tabCount) |
|
rects = new Rectangle[tabCount]; |
|
|
if (tabCount == rects.length) |
|
|
return; |
|
|
else |
|
2396 |
{ |
{ |
2397 |
int numToCopy = Math.min(tabCount, rects.length); |
Rectangle[] old = rects; |
2398 |
Rectangle[] tmp = new Rectangle[tabCount]; |
rects = new Rectangle[tabCount]; |
2399 |
System.arraycopy(rects, 0, tmp, 0, numToCopy); |
System.arraycopy(old, 0, rects, 0, old.length); |
2400 |
rects = tmp; |
for (int i = old.length; i < rects.length; i++) |
2401 |
|
rects[i] = new Rectangle(); |
2402 |
} |
} |
2403 |
} |
} |
2404 |
|
|
2756 |
*/ |
*/ |
2757 |
protected FontMetrics getFontMetrics() |
protected FontMetrics getFontMetrics() |
2758 |
{ |
{ |
2759 |
FontMetrics fm = tabPane.getToolkit().getFontMetrics(tabPane.getFont()); |
FontMetrics fm = tabPane.getFontMetrics(tabPane.getFont()); |
2760 |
return fm; |
return fm; |
2761 |
} |
} |
2762 |
|
|