incrButton = createIncreaseButton();
decrButton = createDecreaseButton();
}
- tabPane.layout();
+ tabPane.revalidate();
tabPane.repaint();
}
}
*/
public void calculateLayoutInfo()
{
+ assureRectsCreated(tabPane.getTabCount());
+ contentRect = SwingUtilities.calculateInnerArea(tabPane, contentRect);
+
calculateTabRects(tabPane.getTabPlacement(), tabPane.getTabCount());
if (tabPane.getSelectedIndex() != -1)
componentWidth = Math.max(componentWidth, dims.width);
}
}
- Insets insets = tabPane.getInsets();
-
if (tabPlacement == SwingConstants.TOP
|| tabPlacement == SwingConstants.BOTTOM)
{
{
if (tabCount == 0)
return;
- assureRectsCreated(tabCount);
FontMetrics fm = getFontMetrics();
SwingUtilities.calculateInnerArea(tabPane, calcRect);
{
if (tabCount == 0)
return;
- assureRectsCreated(tabCount);
FontMetrics fm = getFontMetrics();
SwingUtilities.calculateInnerArea(tabPane, calcRect);
Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
Insets insets = tabPane.getInsets();
- int max = 0;
int runs = 1;
int start = 0;
int top = 0;
{
int maxHeight = calculateMaxTabHeight(tabPlacement);
calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;
- max = calcRect.width + tabAreaInsets.left + insets.left;
start = tabAreaInsets.left + insets.left;
int width = 0;
int runWidth = start;
int maxWidth = calculateMaxTabWidth(tabPlacement);
calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom;
- max = calcRect.height + tabAreaInsets.top;
int height = 0;
start = tabAreaInsets.top + insets.top;
int runHeight = start;
if (tabCount == 0)
return;
int tabPlacement = tabPane.getTabPlacement();
- incrButton.hide();
- decrButton.hide();
+ incrButton.setVisible(false);
+ decrButton.setVisible(false);
if (tabPlacement == SwingConstants.TOP
|| tabPlacement == SwingConstants.BOTTOM)
{
decrDims.width, tabAreaRect.height);
tabAreaRect.width -= decrDims.width + incrDims.width;
- incrButton.show();
- decrButton.show();
+ incrButton.setVisible(true);
+ decrButton.setVisible(true);
}
}
incrDims.height);
tabAreaRect.height -= decrDims.height + incrDims.height;
- incrButton.show();
- decrButton.show();
+ incrButton.setVisible(true);
+ decrButton.setVisible(true);
}
}
viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width,
public BasicTabbedPaneUI()
{
super();
+ rects = new Rectangle[0];
+ tabRuns = new int[10];
}
/**
layoutManager = createLayoutManager();
tabPane.setLayout(layoutManager);
- tabPane.layout();
}
}
textIconGap = UIManager.getInt("TabbedPane.textIconGap");
tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay");
- tabInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabInsets");
+ tabInsets = UIManager.getInsets("TabbedPane.tabInsets");
selectedTabPadInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabPadInsets");
- tabAreaInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabAreaInsets");
+ tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets");
contentBorderInsets = UIManager.getInsets("TabbedPane.tabbedPaneContentBorderInsets");
calcRect = new Rectangle();
protected void paintIcon(Graphics g, int tabPlacement, int tabIndex,
Icon icon, Rectangle iconRect, boolean isSelected)
{
- icon.paintIcon(tabPane, g, iconRect.x, iconRect.y);
+ if (icon != null)
+ icon.paintIcon(tabPane, g, iconRect.x, iconRect.y);
}
/**
protected void paintContentBorder(Graphics g, int tabPlacement,
int selectedIndex)
{
- Insets insets = getContentBorderInsets(tabPlacement);
int x = contentRect.x;
int y = contentRect.y;
int w = contentRect.width;
*/
protected void assureRectsCreated(int tabCount)
{
- if (rects == null)
- rects = new Rectangle[tabCount];
- if (tabCount == rects.length)
- return;
- else
+ if (rects.length < tabCount)
{
- int numToCopy = Math.min(tabCount, rects.length);
- Rectangle[] tmp = new Rectangle[tabCount];
- System.arraycopy(rects, 0, tmp, 0, numToCopy);
- rects = tmp;
+ Rectangle[] old = rects;
+ rects = new Rectangle[tabCount];
+ System.arraycopy(old, 0, rects, 0, old.length);
+ for (int i = old.length; i < rects.length; i++)
+ rects[i] = new Rectangle();
}
}
*/
protected FontMetrics getFontMetrics()
{
- FontMetrics fm = tabPane.getToolkit().getFontMetrics(tabPane.getFont());
+ FontMetrics fm = tabPane.getFontMetrics(tabPane.getFont());
return fm;
}