rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
Object s = ev.getSource(); if (tabPane != ev.getSource()) { ev.setSource(tabPane); tabPane.dispatchEvent(ev); ev.setSource(s); }
public void mouseMoved(MouseEvent ev) { int tabIndex = tabForCoordinate(tabPane, ev.getX(), ev.getY()); setRolloverTab(tabIndex); }
if (tabPane.isEnabled())
Object s = e.getSource(); if (tabPane != e.getSource()) { redispatchEvent(e); e.setSource(s); } int placement = tabPane.getTabPlacement(); if (s == incrButton) { if(!incrButton.isEnabled()) return; currentScrollLocation++; switch (placement) { case JTabbedPane.TOP: case JTabbedPane.BOTTOM: currentScrollOffset = getTabAreaInsets(placement).left; for (int i = 0; i < currentScrollLocation; i++) currentScrollOffset += rects[i].width; break; default: currentScrollOffset = getTabAreaInsets(placement).top; for (int i = 0; i < currentScrollLocation; i++) currentScrollOffset += rects[i].height; break; } updateViewPosition(); updateButtons(); tabPane.repaint(); } else if (s == decrButton) { if(!decrButton.isEnabled()) return; if (currentScrollLocation > 0) currentScrollLocation--; currentScrollOffset = 0; switch (placement) { case JTabbedPane.TOP: case JTabbedPane.BOTTOM: if (currentScrollLocation > 0) currentScrollOffset = getTabAreaInsets(placement).left; for (int i = 0; i < currentScrollLocation; i++) currentScrollOffset += rects[i].width; break; default: if (currentScrollLocation > 0) currentScrollOffset = getTabAreaInsets(placement).top; for (int i = 0; i < currentScrollLocation; i++) currentScrollOffset += rects[i].height; } updateViewPosition(); updateButtons(); tabPane.repaint(); } else if (tabPane.isEnabled())
public void mousePressed(MouseEvent e) { if (tabPane.isEnabled()) { int index = tabForCoordinate(tabPane, e.getX(), e.getY()); if (index >= 0 && tabPane.isEnabledAt(index)) { tabPane.setSelectedIndex(index); } } }
if (index >= 0 && tabPane.isEnabledAt(index))
if (!tabPane.isEnabledAt(index)) return; if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT && s == panel) { scrollTab(index, placement); tabPane.setSelectedIndex(index); tabPane.repaint(); } else
public void mousePressed(MouseEvent e) { if (tabPane.isEnabled()) { int index = tabForCoordinate(tabPane, e.getX(), e.getY()); if (index >= 0 && tabPane.isEnabledAt(index)) { tabPane.setSelectedIndex(index); } } }
paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
int placement = tabPane.getTabPlacement(); g.setColor(highlight); if (placement == SwingUtilities.TOP || placement == SwingUtilities.BOTTOM) g.fillRect(currentScrollOffset, 0, tabAreaRect.width, tabAreaRect.height); else g.fillRect(0, currentScrollOffset, tabAreaRect.width, tabAreaRect.height); paintTabArea(g, placement, tabPane.getSelectedIndex());
public void paint(Graphics g, JComponent c) { paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex()); }
setUI((PanelUI) new ScrollingPanelUI());
setUI(new ScrollingPanelUI());
public void updateUI() { setUI((PanelUI) new ScrollingPanelUI()); }
if (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT)
public void stateChanged(ChangeEvent e) { selectedRun = getRunForTab(tabPane.getTabCount(), tabPane.getSelectedIndex()); tabPane.revalidate(); tabPane.repaint(); }
for (int i = 0; i < tabPane.getTabCount(); i++)
int count = tabPane.getTabCount(); for (int i = 0; i < count; i++)
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; Component c; Dimension dims; // Find out the minimum/preferred size to display the largest child // of the tabbed pane. for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; dims = minimum ? c.getMinimumSize() : c.getPreferredSize(); if (dims != null) { height = Math.max(height, dims.height); width = Math.max(width, dims.width); } } Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, width); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width - tabAreaInsets.left - tabAreaInsets.right); height += tabAreaHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, height); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height - tabAreaInsets.top - tabAreaInsets.bottom); width += tabAreaWidth; } Insets tabPaneInsets = tabPane.getInsets(); return new Dimension(width + tabPaneInsets.left + tabPaneInsets.right, height + tabPaneInsets.top + tabPaneInsets.bottom); }
int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, width); int tabAreaHeight = preferredTabAreaHeight(tabPlacement,
width = Math.max(calculateMaxTabWidth(tabPlacement), width); height += preferredTabAreaHeight(tabPlacement,
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; Component c; Dimension dims; // Find out the minimum/preferred size to display the largest child // of the tabbed pane. for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; dims = minimum ? c.getMinimumSize() : c.getPreferredSize(); if (dims != null) { height = Math.max(height, dims.height); width = Math.max(width, dims.width); } } Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, width); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width - tabAreaInsets.left - tabAreaInsets.right); height += tabAreaHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, height); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height - tabAreaInsets.top - tabAreaInsets.bottom); width += tabAreaWidth; } Insets tabPaneInsets = tabPane.getInsets(); return new Dimension(width + tabPaneInsets.left + tabPaneInsets.right, height + tabPaneInsets.top + tabPaneInsets.bottom); }
height += tabAreaHeight;
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; Component c; Dimension dims; // Find out the minimum/preferred size to display the largest child // of the tabbed pane. for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; dims = minimum ? c.getMinimumSize() : c.getPreferredSize(); if (dims != null) { height = Math.max(height, dims.height); width = Math.max(width, dims.width); } } Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, width); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width - tabAreaInsets.left - tabAreaInsets.right); height += tabAreaHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, height); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height - tabAreaInsets.top - tabAreaInsets.bottom); width += tabAreaWidth; } Insets tabPaneInsets = tabPane.getInsets(); return new Dimension(width + tabPaneInsets.left + tabPaneInsets.right, height + tabPaneInsets.top + tabPaneInsets.bottom); }
int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, height); int tabAreaWidth = preferredTabAreaWidth(tabPlacement,
height = Math.max(calculateMaxTabHeight(tabPlacement), height); width += preferredTabAreaWidth(tabPlacement,
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; Component c; Dimension dims; // Find out the minimum/preferred size to display the largest child // of the tabbed pane. for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; dims = minimum ? c.getMinimumSize() : c.getPreferredSize(); if (dims != null) { height = Math.max(height, dims.height); width = Math.max(width, dims.width); } } Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, width); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width - tabAreaInsets.left - tabAreaInsets.right); height += tabAreaHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, height); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height - tabAreaInsets.top - tabAreaInsets.bottom); width += tabAreaWidth; } Insets tabPaneInsets = tabPane.getInsets(); return new Dimension(width + tabPaneInsets.left + tabPaneInsets.right, height + tabPaneInsets.top + tabPaneInsets.bottom); }
width += tabAreaWidth;
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; Component c; Dimension dims; // Find out the minimum/preferred size to display the largest child // of the tabbed pane. for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; dims = minimum ? c.getMinimumSize() : c.getPreferredSize(); if (dims != null) { height = Math.max(height, dims.height); width = Math.max(width, dims.width); } } Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, width); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width - tabAreaInsets.left - tabAreaInsets.right); height += tabAreaHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, height); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height - tabAreaInsets.top - tabAreaInsets.bottom); width += tabAreaWidth; } Insets tabPaneInsets = tabPane.getInsets(); return new Dimension(width + tabPaneInsets.left + tabPaneInsets.right, height + tabPaneInsets.top + tabPaneInsets.bottom); }
x = size.width - (insets.right + tabAreaInsets.right) - maxTabWidth;
x = size.width - (insets.right + tabAreaInsets.right) - maxTabWidth - 1;
protected void calculateTabRects(int tabPlacement, int tabCount) { Insets insets = tabPane.getInsets(); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Dimension size = tabPane.getSize(); // The coordinates of the upper left corner of the tab area. int x; int y; // The location at which the runs must be broken. int breakAt; // Calculate the bounds for the tab area. switch (tabPlacement) { case LEFT: maxTabWidth = calculateMaxTabWidth(tabPlacement); x = insets.left + tabAreaInsets.left; y = insets.top + tabAreaInsets.top; breakAt = size.height - (insets.bottom + tabAreaInsets.bottom); break; case RIGHT: maxTabWidth = calculateMaxTabWidth(tabPlacement); x = size.width - (insets.right + tabAreaInsets.right) - maxTabWidth; y = insets.top + tabAreaInsets.top; breakAt = size.height - (insets.bottom + tabAreaInsets.bottom); break; case BOTTOM: maxTabHeight = calculateMaxTabHeight(tabPlacement); x = insets.left + tabAreaInsets.left; y = size.height - (insets.bottom + tabAreaInsets.bottom) - maxTabHeight; breakAt = size.width - (insets.right + tabAreaInsets.right); break; case TOP: default: maxTabHeight = calculateMaxTabHeight(tabPlacement); x = insets.left + tabAreaInsets.left; y = insets.top + tabAreaInsets.top; breakAt = size.width - (insets.right + tabAreaInsets.right); break; } if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); runCount = 0; selectedRun = -1; int selectedIndex = tabPane.getSelectedIndex(); Rectangle rect; // Go through all the tabs and build the tab runs. if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { for (int i = 0; i < tabCount; i++) { rect = rects[i]; if (i > 0) { rect.x = rects[i - 1].x + rects[i - 1].width; } else { tabRuns[0] = 0; runCount = 1; maxTabWidth = 0; rect.x = x; } rect.width = calculateTabWidth(tabPlacement, i, fm); maxTabWidth = Math.max(maxTabWidth, rect.width); if (rect.x != 2 + insets.left && rect.x + rect.width > breakAt) { if (runCount > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runCount] = i; runCount++; rect.x = x; } rect.y = y; rect.height = maxTabHeight; if (i == selectedIndex) selectedRun = runCount - 1; } } else { for (int i = 0; i < tabCount; i++) { rect = rects[i]; if (i > 0) { rect.y = rects[i - 1].y + rects[i - 1].height; } else { tabRuns[0] = 0; runCount = 1; maxTabHeight = 0; rect.y = y; } rect.height = calculateTabHeight(tabPlacement, i, fm.getHeight()); maxTabHeight = Math.max(maxTabHeight, rect.height); if (rect.y != 2 + insets.top && rect.y + rect.height > breakAt) { if (runCount > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runCount] = i; runCount++; rect.y = y; } rect.x = x; rect.width = maxTabWidth; if (i == selectedIndex) selectedRun = runCount - 1; } } if (runCount > 1) { int start; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) start = y; else start = x; normalizeTabRuns(tabPlacement, tabCount, start, breakAt); selectedRun = getRunForTab(tabCount, selectedIndex); if (shouldRotateTabRuns(tabPlacement)) { rotateTabRuns(tabPlacement, selectedRun); } } // Pad the runs. int tabRunOverlay = getTabRunOverlay(tabPlacement); for (int i = runCount - 1; i >= 0; --i) { int start = tabRuns[i]; int nextIndex; if (i == runCount - 1) nextIndex = 0; else nextIndex = i + 1; int next = tabRuns[nextIndex]; int end = next != 0 ? next - 1 : tabCount - 1; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { for (int j = start; j <= end; ++j) { rect = rects[j]; rect.y = y; rect.x += getTabRunIndent(tabPlacement, i); } if (shouldPadTabRun(tabPlacement, i)) { padTabRun(tabPlacement, start, end, breakAt); } if (tabPlacement == BOTTOM) y -= maxTabHeight - tabRunOverlay; else y += maxTabHeight - tabRunOverlay; } else { for (int j = start; j <= end; ++j) { rect = rects[j]; rect.x = x; rect.y += getTabRunIndent(tabPlacement, i); } if (shouldPadTabRun(tabPlacement, i)) { padTabRun(tabPlacement, start, end, breakAt); } if (tabPlacement == RIGHT) x -= maxTabWidth - tabRunOverlay; else x += maxTabWidth - tabRunOverlay; } } padSelectedTab(tabPlacement, selectedIndex); }
- maxTabHeight;
- maxTabHeight - 1;
protected void calculateTabRects(int tabPlacement, int tabCount) { Insets insets = tabPane.getInsets(); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Dimension size = tabPane.getSize(); // The coordinates of the upper left corner of the tab area. int x; int y; // The location at which the runs must be broken. int breakAt; // Calculate the bounds for the tab area. switch (tabPlacement) { case LEFT: maxTabWidth = calculateMaxTabWidth(tabPlacement); x = insets.left + tabAreaInsets.left; y = insets.top + tabAreaInsets.top; breakAt = size.height - (insets.bottom + tabAreaInsets.bottom); break; case RIGHT: maxTabWidth = calculateMaxTabWidth(tabPlacement); x = size.width - (insets.right + tabAreaInsets.right) - maxTabWidth; y = insets.top + tabAreaInsets.top; breakAt = size.height - (insets.bottom + tabAreaInsets.bottom); break; case BOTTOM: maxTabHeight = calculateMaxTabHeight(tabPlacement); x = insets.left + tabAreaInsets.left; y = size.height - (insets.bottom + tabAreaInsets.bottom) - maxTabHeight; breakAt = size.width - (insets.right + tabAreaInsets.right); break; case TOP: default: maxTabHeight = calculateMaxTabHeight(tabPlacement); x = insets.left + tabAreaInsets.left; y = insets.top + tabAreaInsets.top; breakAt = size.width - (insets.right + tabAreaInsets.right); break; } if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); runCount = 0; selectedRun = -1; int selectedIndex = tabPane.getSelectedIndex(); Rectangle rect; // Go through all the tabs and build the tab runs. if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { for (int i = 0; i < tabCount; i++) { rect = rects[i]; if (i > 0) { rect.x = rects[i - 1].x + rects[i - 1].width; } else { tabRuns[0] = 0; runCount = 1; maxTabWidth = 0; rect.x = x; } rect.width = calculateTabWidth(tabPlacement, i, fm); maxTabWidth = Math.max(maxTabWidth, rect.width); if (rect.x != 2 + insets.left && rect.x + rect.width > breakAt) { if (runCount > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runCount] = i; runCount++; rect.x = x; } rect.y = y; rect.height = maxTabHeight; if (i == selectedIndex) selectedRun = runCount - 1; } } else { for (int i = 0; i < tabCount; i++) { rect = rects[i]; if (i > 0) { rect.y = rects[i - 1].y + rects[i - 1].height; } else { tabRuns[0] = 0; runCount = 1; maxTabHeight = 0; rect.y = y; } rect.height = calculateTabHeight(tabPlacement, i, fm.getHeight()); maxTabHeight = Math.max(maxTabHeight, rect.height); if (rect.y != 2 + insets.top && rect.y + rect.height > breakAt) { if (runCount > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runCount] = i; runCount++; rect.y = y; } rect.x = x; rect.width = maxTabWidth; if (i == selectedIndex) selectedRun = runCount - 1; } } if (runCount > 1) { int start; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) start = y; else start = x; normalizeTabRuns(tabPlacement, tabCount, start, breakAt); selectedRun = getRunForTab(tabCount, selectedIndex); if (shouldRotateTabRuns(tabPlacement)) { rotateTabRuns(tabPlacement, selectedRun); } } // Pad the runs. int tabRunOverlay = getTabRunOverlay(tabPlacement); for (int i = runCount - 1; i >= 0; --i) { int start = tabRuns[i]; int nextIndex; if (i == runCount - 1) nextIndex = 0; else nextIndex = i + 1; int next = tabRuns[nextIndex]; int end = next != 0 ? next - 1 : tabCount - 1; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { for (int j = start; j <= end; ++j) { rect = rects[j]; rect.y = y; rect.x += getTabRunIndent(tabPlacement, i); } if (shouldPadTabRun(tabPlacement, i)) { padTabRun(tabPlacement, start, end, breakAt); } if (tabPlacement == BOTTOM) y -= maxTabHeight - tabRunOverlay; else y += maxTabHeight - tabRunOverlay; } else { for (int j = start; j <= end; ++j) { rect = rects[j]; rect.x = x; rect.y += getTabRunIndent(tabPlacement, i); } if (shouldPadTabRun(tabPlacement, i)) { padTabRun(tabPlacement, start, end, breakAt); } if (tabPlacement == RIGHT) x -= maxTabWidth - tabRunOverlay; else x += maxTabWidth - tabRunOverlay; } } padSelectedTab(tabPlacement, selectedIndex); }
else start = x;
protected void calculateTabRects(int tabPlacement, int tabCount) { Insets insets = tabPane.getInsets(); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Dimension size = tabPane.getSize(); // The coordinates of the upper left corner of the tab area. int x; int y; // The location at which the runs must be broken. int breakAt; // Calculate the bounds for the tab area. switch (tabPlacement) { case LEFT: maxTabWidth = calculateMaxTabWidth(tabPlacement); x = insets.left + tabAreaInsets.left; y = insets.top + tabAreaInsets.top; breakAt = size.height - (insets.bottom + tabAreaInsets.bottom); break; case RIGHT: maxTabWidth = calculateMaxTabWidth(tabPlacement); x = size.width - (insets.right + tabAreaInsets.right) - maxTabWidth; y = insets.top + tabAreaInsets.top; breakAt = size.height - (insets.bottom + tabAreaInsets.bottom); break; case BOTTOM: maxTabHeight = calculateMaxTabHeight(tabPlacement); x = insets.left + tabAreaInsets.left; y = size.height - (insets.bottom + tabAreaInsets.bottom) - maxTabHeight; breakAt = size.width - (insets.right + tabAreaInsets.right); break; case TOP: default: maxTabHeight = calculateMaxTabHeight(tabPlacement); x = insets.left + tabAreaInsets.left; y = insets.top + tabAreaInsets.top; breakAt = size.width - (insets.right + tabAreaInsets.right); break; } if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); runCount = 0; selectedRun = -1; int selectedIndex = tabPane.getSelectedIndex(); Rectangle rect; // Go through all the tabs and build the tab runs. if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { for (int i = 0; i < tabCount; i++) { rect = rects[i]; if (i > 0) { rect.x = rects[i - 1].x + rects[i - 1].width; } else { tabRuns[0] = 0; runCount = 1; maxTabWidth = 0; rect.x = x; } rect.width = calculateTabWidth(tabPlacement, i, fm); maxTabWidth = Math.max(maxTabWidth, rect.width); if (rect.x != 2 + insets.left && rect.x + rect.width > breakAt) { if (runCount > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runCount] = i; runCount++; rect.x = x; } rect.y = y; rect.height = maxTabHeight; if (i == selectedIndex) selectedRun = runCount - 1; } } else { for (int i = 0; i < tabCount; i++) { rect = rects[i]; if (i > 0) { rect.y = rects[i - 1].y + rects[i - 1].height; } else { tabRuns[0] = 0; runCount = 1; maxTabHeight = 0; rect.y = y; } rect.height = calculateTabHeight(tabPlacement, i, fm.getHeight()); maxTabHeight = Math.max(maxTabHeight, rect.height); if (rect.y != 2 + insets.top && rect.y + rect.height > breakAt) { if (runCount > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runCount] = i; runCount++; rect.y = y; } rect.x = x; rect.width = maxTabWidth; if (i == selectedIndex) selectedRun = runCount - 1; } } if (runCount > 1) { int start; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) start = y; else start = x; normalizeTabRuns(tabPlacement, tabCount, start, breakAt); selectedRun = getRunForTab(tabCount, selectedIndex); if (shouldRotateTabRuns(tabPlacement)) { rotateTabRuns(tabPlacement, selectedRun); } } // Pad the runs. int tabRunOverlay = getTabRunOverlay(tabPlacement); for (int i = runCount - 1; i >= 0; --i) { int start = tabRuns[i]; int nextIndex; if (i == runCount - 1) nextIndex = 0; else nextIndex = i + 1; int next = tabRuns[nextIndex]; int end = next != 0 ? next - 1 : tabCount - 1; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { for (int j = start; j <= end; ++j) { rect = rects[j]; rect.y = y; rect.x += getTabRunIndent(tabPlacement, i); } if (shouldPadTabRun(tabPlacement, i)) { padTabRun(tabPlacement, start, end, breakAt); } if (tabPlacement == BOTTOM) y -= maxTabHeight - tabRunOverlay; else y += maxTabHeight - tabRunOverlay; } else { for (int j = start; j <= end; ++j) { rect = rects[j]; rect.x = x; rect.y += getTabRunIndent(tabPlacement, i); } if (shouldPadTabRun(tabPlacement, i)) { padTabRun(tabPlacement, start, end, breakAt); } if (tabPlacement == RIGHT) x -= maxTabWidth - tabRunOverlay; else x += maxTabWidth - tabRunOverlay; } } padSelectedTab(tabPlacement, selectedIndex); }
if (runCount == 1) return;
protected void calculateTabRects(int tabPlacement, int tabCount) { Insets insets = tabPane.getInsets(); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Dimension size = tabPane.getSize(); // The coordinates of the upper left corner of the tab area. int x; int y; // The location at which the runs must be broken. int breakAt; // Calculate the bounds for the tab area. switch (tabPlacement) { case LEFT: maxTabWidth = calculateMaxTabWidth(tabPlacement); x = insets.left + tabAreaInsets.left; y = insets.top + tabAreaInsets.top; breakAt = size.height - (insets.bottom + tabAreaInsets.bottom); break; case RIGHT: maxTabWidth = calculateMaxTabWidth(tabPlacement); x = size.width - (insets.right + tabAreaInsets.right) - maxTabWidth; y = insets.top + tabAreaInsets.top; breakAt = size.height - (insets.bottom + tabAreaInsets.bottom); break; case BOTTOM: maxTabHeight = calculateMaxTabHeight(tabPlacement); x = insets.left + tabAreaInsets.left; y = size.height - (insets.bottom + tabAreaInsets.bottom) - maxTabHeight; breakAt = size.width - (insets.right + tabAreaInsets.right); break; case TOP: default: maxTabHeight = calculateMaxTabHeight(tabPlacement); x = insets.left + tabAreaInsets.left; y = insets.top + tabAreaInsets.top; breakAt = size.width - (insets.right + tabAreaInsets.right); break; } if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); runCount = 0; selectedRun = -1; int selectedIndex = tabPane.getSelectedIndex(); Rectangle rect; // Go through all the tabs and build the tab runs. if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { for (int i = 0; i < tabCount; i++) { rect = rects[i]; if (i > 0) { rect.x = rects[i - 1].x + rects[i - 1].width; } else { tabRuns[0] = 0; runCount = 1; maxTabWidth = 0; rect.x = x; } rect.width = calculateTabWidth(tabPlacement, i, fm); maxTabWidth = Math.max(maxTabWidth, rect.width); if (rect.x != 2 + insets.left && rect.x + rect.width > breakAt) { if (runCount > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runCount] = i; runCount++; rect.x = x; } rect.y = y; rect.height = maxTabHeight; if (i == selectedIndex) selectedRun = runCount - 1; } } else { for (int i = 0; i < tabCount; i++) { rect = rects[i]; if (i > 0) { rect.y = rects[i - 1].y + rects[i - 1].height; } else { tabRuns[0] = 0; runCount = 1; maxTabHeight = 0; rect.y = y; } rect.height = calculateTabHeight(tabPlacement, i, fm.getHeight()); maxTabHeight = Math.max(maxTabHeight, rect.height); if (rect.y != 2 + insets.top && rect.y + rect.height > breakAt) { if (runCount > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runCount] = i; runCount++; rect.y = y; } rect.x = x; rect.width = maxTabWidth; if (i == selectedIndex) selectedRun = runCount - 1; } } if (runCount > 1) { int start; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) start = y; else start = x; normalizeTabRuns(tabPlacement, tabCount, start, breakAt); selectedRun = getRunForTab(tabCount, selectedIndex); if (shouldRotateTabRuns(tabPlacement)) { rotateTabRuns(tabPlacement, selectedRun); } } // Pad the runs. int tabRunOverlay = getTabRunOverlay(tabPlacement); for (int i = runCount - 1; i >= 0; --i) { int start = tabRuns[i]; int nextIndex; if (i == runCount - 1) nextIndex = 0; else nextIndex = i + 1; int next = tabRuns[nextIndex]; int end = next != 0 ? next - 1 : tabCount - 1; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { for (int j = start; j <= end; ++j) { rect = rects[j]; rect.y = y; rect.x += getTabRunIndent(tabPlacement, i); } if (shouldPadTabRun(tabPlacement, i)) { padTabRun(tabPlacement, start, end, breakAt); } if (tabPlacement == BOTTOM) y -= maxTabHeight - tabRunOverlay; else y += maxTabHeight - tabRunOverlay; } else { for (int j = start; j <= end; ++j) { rect = rects[j]; rect.x = x; rect.y += getTabRunIndent(tabPlacement, i); } if (shouldPadTabRun(tabPlacement, i)) { padTabRun(tabPlacement, start, end, breakAt); } if (tabPlacement == RIGHT) x -= maxTabWidth - tabRunOverlay; else x += maxTabWidth - tabRunOverlay; } } padSelectedTab(tabPlacement, selectedIndex); }
Component selectedComponent = tabPane.getComponentAt(selectedIndex);
Component selectedComponent = null; if (selectedIndex >= 0) selectedComponent = tabPane.getComponentAt(selectedIndex);
public void layoutContainer(Container parent) { calculateLayoutInfo(); int tabPlacement = tabPane.getTabPlacement(); Insets insets = tabPane.getInsets(); int selectedIndex = tabPane.getSelectedIndex(); Component selectedComponent = tabPane.getComponentAt(selectedIndex); // The RI doesn't seem to change the component if the new selected // component == null. This is probably so that applications can add // one single component for every tab. if (selectedComponent != null) { setVisibleComponent(selectedComponent); } int childCount = tabPane.getComponentCount(); if (childCount > 0) { int compX; int compY; int tabAreaWidth = 0; int tabAreaHeight = 0; switch (tabPlacement) { case LEFT: tabAreaWidth = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); compX = tabAreaWidth + insets.left + contentBorderInsets.left; compY = insets.top + contentBorderInsets.top; break; case RIGHT: tabAreaWidth = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); compX = insets.left + contentBorderInsets.left; compY = insets.top + contentBorderInsets.top; break; case BOTTOM: tabAreaHeight = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); compX = insets.left + contentBorderInsets.left; compY = insets.top + contentBorderInsets.top; break; case TOP: default: tabAreaHeight = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); compX = insets.left + contentBorderInsets.left; compY = tabAreaHeight + insets.top + contentBorderInsets.top; } Rectangle bounds = tabPane.getBounds(); int compWidth = bounds.width - tabAreaWidth - insets.left - insets.right - contentBorderInsets.left - contentBorderInsets.right; int compHeight = bounds.height - tabAreaHeight - insets.top - insets.bottom - contentBorderInsets.top - contentBorderInsets.bottom; for (int i = 0; i < childCount; ++i) { Component c = tabPane.getComponent(i); c.setBounds(compX, compY, compWidth, compHeight); } } }
return calculateSize(false);
return calculateSize(true);
public Dimension minimumLayoutSize(Container parent) { return calculateSize(false); }
Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left;
int first = tabRuns[i]; int last = lastTabInRun(tabCount, i); int currX = start;
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top;
int first = tabRuns[i]; int last = lastTabInRun(tabCount, i); int currY = start;
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
if (runCount == 1 || selectedRun == 1 || selectedRun == -1)
if (runCount == 1 || selectedRun == 0 || selectedRun == -1)
protected void rotateTabRuns(int tabPlacement, int selectedRun) { if (runCount == 1 || selectedRun == 1 || selectedRun == -1) return; int[] newTabRuns = new int[tabRuns.length]; int currentRun = selectedRun; int i = 1; do { newTabRuns[i] = tabRuns[currentRun]; currentRun = getNextTabRun(currentRun); i++; } while (i < runCount); if (runCount > 1) newTabRuns[0] = tabRuns[currentRun]; tabRuns = newTabRuns; BasicTabbedPaneUI.this.selectedRun = 1; }
int i = 1;
int i = 0;
protected void rotateTabRuns(int tabPlacement, int selectedRun) { if (runCount == 1 || selectedRun == 1 || selectedRun == -1) return; int[] newTabRuns = new int[tabRuns.length]; int currentRun = selectedRun; int i = 1; do { newTabRuns[i] = tabRuns[currentRun]; currentRun = getNextTabRun(currentRun); i++; } while (i < runCount); if (runCount > 1) newTabRuns[0] = tabRuns[currentRun]; tabRuns = newTabRuns; BasicTabbedPaneUI.this.selectedRun = 1; }
if (runCount > 1) newTabRuns[0] = tabRuns[currentRun];
protected void rotateTabRuns(int tabPlacement, int selectedRun) { if (runCount == 1 || selectedRun == 1 || selectedRun == -1) return; int[] newTabRuns = new int[tabRuns.length]; int currentRun = selectedRun; int i = 1; do { newTabRuns[i] = tabRuns[currentRun]; currentRun = getNextTabRun(currentRun); i++; } while (i < runCount); if (runCount > 1) newTabRuns[0] = tabRuns[currentRun]; tabRuns = newTabRuns; BasicTabbedPaneUI.this.selectedRun = 1; }
int runs = 1; int start = 0; int top = 0;
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
start = tabAreaInsets.left + insets.left;
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
int runWidth = start; top = insets.top + tabAreaInsets.top;
int runWidth = tabAreaInsets.left + insets.left; int top = insets.top + tabAreaInsets.top;
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
rects[i] = new Rectangle(runWidth, top, width, maxHeight);
rects[i].setBounds(runWidth, top, width, maxHeight);
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom;
tabAreaRect.height = maxTabHeight + tabAreaInsets.top + tabAreaInsets.bottom;
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
start = tabAreaInsets.top + insets.top; int runHeight = start;
int runHeight = tabAreaInsets.top + insets.top;;
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
top = insets.left + tabAreaInsets.left;
int left = insets.left + tabAreaInsets.left;
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
rects[i] = new Rectangle(top, runHeight, maxWidth, height);
rects[i].setBounds(left, runHeight, maxWidth, height);
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right;
tabAreaRect.width = maxTabWidth + tabAreaInsets.left + tabAreaInsets.right;
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray();
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
padSelectedTab(tabPlacement, tabPane.getSelectedIndex());
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int runs = 1; int start = 0; int top = 0; if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; start = tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; top = insets.top + tabAreaInsets.top; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); rects[i] = new Rectangle(runWidth, top, width, maxHeight); runWidth += width; } tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; int height = 0; start = tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); top = insets.left + tabAreaInsets.left; for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); rects[i] = new Rectangle(top, runHeight, maxWidth, height); runHeight += height; } tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; if (runCount > tabRuns.length) expandTabRunsArray(); padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
Point p = null;
public void layoutContainer(Container pane) { super.layoutContainer(pane); int tabCount = tabPane.getTabCount(); Point p = null; if (tabCount == 0) return; int tabPlacement = tabPane.getTabPlacement(); incrButton.setVisible(false); decrButton.setVisible(false); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x + rects[tabCount - 1].width) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width - decrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); incrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); tabAreaRect.width -= decrDims.width + incrDims.width; incrButton.setVisible(true); decrButton.setVisible(true); } } if (tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT) { if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y + rects[tabCount - 1].height) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height - decrDims.height, tabAreaRect.width, decrDims.height); incrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height, tabAreaRect.width, incrDims.height); tabAreaRect.height -= decrDims.height + incrDims.height; incrButton.setVisible(true); decrButton.setVisible(true); } } viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, tabAreaRect.height); int tabC = tabPane.getTabCount() - 1; if (tabCount > 0) { int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width); int h = Math.max(rects[tabC].height, tabAreaRect.height); p = findPointForIndex(currentScrollLocation); // we want to cover that entire space so that borders that run under // the tab area don't show up when we move the viewport around. panel.setSize(w + p.x, h + p.y); } viewport.setViewPosition(p); viewport.repaint(); }
incrButton.setVisible(false); decrButton.setVisible(false);
public void layoutContainer(Container pane) { super.layoutContainer(pane); int tabCount = tabPane.getTabCount(); Point p = null; if (tabCount == 0) return; int tabPlacement = tabPane.getTabPlacement(); incrButton.setVisible(false); decrButton.setVisible(false); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x + rects[tabCount - 1].width) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width - decrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); incrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); tabAreaRect.width -= decrDims.width + incrDims.width; incrButton.setVisible(true); decrButton.setVisible(true); } } if (tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT) { if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y + rects[tabCount - 1].height) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height - decrDims.height, tabAreaRect.width, decrDims.height); incrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height, tabAreaRect.width, incrDims.height); tabAreaRect.height -= decrDims.height + incrDims.height; incrButton.setVisible(true); decrButton.setVisible(true); } } viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, tabAreaRect.height); int tabC = tabPane.getTabCount() - 1; if (tabCount > 0) { int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width); int h = Math.max(rects[tabC].height, tabAreaRect.height); p = findPointForIndex(currentScrollLocation); // we want to cover that entire space so that borders that run under // the tab area don't show up when we move the viewport around. panel.setSize(w + p.x, h + p.y); } viewport.setViewPosition(p); viewport.repaint(); }
tabAreaRect.height);
decrDims.height);
public void layoutContainer(Container pane) { super.layoutContainer(pane); int tabCount = tabPane.getTabCount(); Point p = null; if (tabCount == 0) return; int tabPlacement = tabPane.getTabPlacement(); incrButton.setVisible(false); decrButton.setVisible(false); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x + rects[tabCount - 1].width) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width - decrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); incrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); tabAreaRect.width -= decrDims.width + incrDims.width; incrButton.setVisible(true); decrButton.setVisible(true); } } if (tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT) { if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y + rects[tabCount - 1].height) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height - decrDims.height, tabAreaRect.width, decrDims.height); incrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height, tabAreaRect.width, incrDims.height); tabAreaRect.height -= decrDims.height + incrDims.height; incrButton.setVisible(true); decrButton.setVisible(true); } } viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, tabAreaRect.height); int tabC = tabPane.getTabCount() - 1; if (tabCount > 0) { int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width); int h = Math.max(rects[tabC].height, tabAreaRect.height); p = findPointForIndex(currentScrollLocation); // we want to cover that entire space so that borders that run under // the tab area don't show up when we move the viewport around. panel.setSize(w + p.x, h + p.y); } viewport.setViewPosition(p); viewport.repaint(); }
decrDims.width, tabAreaRect.height);
incrDims.width, incrDims.height); } else { decrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width - decrDims.width, tabAreaRect.y + tabAreaRect.height - decrDims.height, decrDims.width, decrDims.height); incrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width, tabAreaRect.y + tabAreaRect.height - incrDims.height, incrDims.width, incrDims.height); }
public void layoutContainer(Container pane) { super.layoutContainer(pane); int tabCount = tabPane.getTabCount(); Point p = null; if (tabCount == 0) return; int tabPlacement = tabPane.getTabPlacement(); incrButton.setVisible(false); decrButton.setVisible(false); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x + rects[tabCount - 1].width) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width - decrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); incrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); tabAreaRect.width -= decrDims.width + incrDims.width; incrButton.setVisible(true); decrButton.setVisible(true); } } if (tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT) { if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y + rects[tabCount - 1].height) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height - decrDims.height, tabAreaRect.width, decrDims.height); incrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height, tabAreaRect.width, incrDims.height); tabAreaRect.height -= decrDims.height + incrDims.height; incrButton.setVisible(true); decrButton.setVisible(true); } } viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, tabAreaRect.height); int tabC = tabPane.getTabCount() - 1; if (tabCount > 0) { int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width); int h = Math.max(rects[tabC].height, tabAreaRect.height); p = findPointForIndex(currentScrollLocation); // we want to cover that entire space so that borders that run under // the tab area don't show up when we move the viewport around. panel.setSize(w + p.x, h + p.y); } viewport.setViewPosition(p); viewport.repaint(); }
tabAreaRect.width, decrDims.height);
decrDims.width, decrDims.height);
public void layoutContainer(Container pane) { super.layoutContainer(pane); int tabCount = tabPane.getTabCount(); Point p = null; if (tabCount == 0) return; int tabPlacement = tabPane.getTabPlacement(); incrButton.setVisible(false); decrButton.setVisible(false); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x + rects[tabCount - 1].width) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width - decrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); incrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); tabAreaRect.width -= decrDims.width + incrDims.width; incrButton.setVisible(true); decrButton.setVisible(true); } } if (tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT) { if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y + rects[tabCount - 1].height) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height - decrDims.height, tabAreaRect.width, decrDims.height); incrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height, tabAreaRect.width, incrDims.height); tabAreaRect.height -= decrDims.height + incrDims.height; incrButton.setVisible(true); decrButton.setVisible(true); } } viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, tabAreaRect.height); int tabC = tabPane.getTabCount() - 1; if (tabCount > 0) { int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width); int h = Math.max(rects[tabC].height, tabAreaRect.height); p = findPointForIndex(currentScrollLocation); // we want to cover that entire space so that borders that run under // the tab area don't show up when we move the viewport around. panel.setSize(w + p.x, h + p.y); } viewport.setViewPosition(p); viewport.repaint(); }
- incrDims.height, tabAreaRect.width,
- incrDims.height, incrDims.width,
public void layoutContainer(Container pane) { super.layoutContainer(pane); int tabCount = tabPane.getTabCount(); Point p = null; if (tabCount == 0) return; int tabPlacement = tabPane.getTabPlacement(); incrButton.setVisible(false); decrButton.setVisible(false); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x + rects[tabCount - 1].width) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width - decrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); incrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); tabAreaRect.width -= decrDims.width + incrDims.width; incrButton.setVisible(true); decrButton.setVisible(true); } } if (tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT) { if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y + rects[tabCount - 1].height) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height - decrDims.height, tabAreaRect.width, decrDims.height); incrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height, tabAreaRect.width, incrDims.height); tabAreaRect.height -= decrDims.height + incrDims.height; incrButton.setVisible(true); decrButton.setVisible(true); } } viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, tabAreaRect.height); int tabC = tabPane.getTabCount() - 1; if (tabCount > 0) { int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width); int h = Math.max(rects[tabC].height, tabAreaRect.height); p = findPointForIndex(currentScrollLocation); // we want to cover that entire space so that borders that run under // the tab area don't show up when we move the viewport around. panel.setSize(w + p.x, h + p.y); } viewport.setViewPosition(p); viewport.repaint(); }
int tabC = tabPane.getTabCount() - 1; if (tabCount > 0) { int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width); int h = Math.max(rects[tabC].height, tabAreaRect.height); p = findPointForIndex(currentScrollLocation); panel.setSize(w + p.x, h + p.y); } viewport.setViewPosition(p);
updateViewPosition();
public void layoutContainer(Container pane) { super.layoutContainer(pane); int tabCount = tabPane.getTabCount(); Point p = null; if (tabCount == 0) return; int tabPlacement = tabPane.getTabPlacement(); incrButton.setVisible(false); decrButton.setVisible(false); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x + rects[tabCount - 1].width) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width - decrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); incrButton.setBounds(tabAreaRect.x + tabAreaRect.width - incrDims.width, tabAreaRect.y, decrDims.width, tabAreaRect.height); tabAreaRect.width -= decrDims.width + incrDims.width; incrButton.setVisible(true); decrButton.setVisible(true); } } if (tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT) { if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y + rects[tabCount - 1].height) { Dimension incrDims = incrButton.getPreferredSize(); Dimension decrDims = decrButton.getPreferredSize(); decrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height - decrDims.height, tabAreaRect.width, decrDims.height); incrButton.setBounds(tabAreaRect.x, tabAreaRect.y + tabAreaRect.height - incrDims.height, tabAreaRect.width, incrDims.height); tabAreaRect.height -= decrDims.height + incrDims.height; incrButton.setVisible(true); decrButton.setVisible(true); } } viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, tabAreaRect.height); int tabC = tabPane.getTabCount() - 1; if (tabCount > 0) { int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width); int h = Math.max(rects[tabC].height, tabAreaRect.height); p = findPointForIndex(currentScrollLocation); // we want to cover that entire space so that borders that run under // the tab area don't show up when we move the viewport around. panel.setSize(w + p.x, h + p.y); } viewport.setViewPosition(p); viewport.repaint(); }
return super.calculateSize(true);
return super.calculateSize(false);
public Dimension preferredLayoutSize(Container parent) { return super.calculateSize(true); }
int width = 0;
int width = insets.bottom + insets.right + 3;
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) { Icon icon = getIconForTab(tabIndex); Insets insets = getTabInsets(tabPlacement, tabIndex); int width = 0; if (icon != null) { Rectangle vr = new Rectangle(); Rectangle ir = new Rectangle(); Rectangle tr = new Rectangle(); layoutLabel(tabPlacement, getFontMetrics(), tabIndex, tabPane.getTitleAt(tabIndex), icon, vr, ir, tr, tabIndex == tabPane.getSelectedIndex()); width = tr.union(ir).width; } else width = metrics.stringWidth(tabPane.getTitleAt(tabIndex)); width += insets.left + insets.right; return width; }
Rectangle vr = new Rectangle(); Rectangle ir = new Rectangle(); Rectangle tr = new Rectangle(); layoutLabel(tabPlacement, getFontMetrics(), tabIndex, tabPane.getTitleAt(tabIndex), icon, vr, ir, tr, tabIndex == tabPane.getSelectedIndex()); width = tr.union(ir).width;
width += icon.getIconWidth() + textIconGap;
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) { Icon icon = getIconForTab(tabIndex); Insets insets = getTabInsets(tabPlacement, tabIndex); int width = 0; if (icon != null) { Rectangle vr = new Rectangle(); Rectangle ir = new Rectangle(); Rectangle tr = new Rectangle(); layoutLabel(tabPlacement, getFontMetrics(), tabIndex, tabPane.getTitleAt(tabIndex), icon, vr, ir, tr, tabIndex == tabPane.getSelectedIndex()); width = tr.union(ir).width; } else width = metrics.stringWidth(tabPane.getTitleAt(tabIndex)); width += insets.left + insets.right; return width; }
width = metrics.stringWidth(tabPane.getTitleAt(tabIndex)); width += insets.left + insets.right;
{ String label = tabPane.getTitleAt(tabIndex); width += metrics.stringWidth(label); }
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) { Icon icon = getIconForTab(tabIndex); Insets insets = getTabInsets(tabPlacement, tabIndex); int width = 0; if (icon != null) { Rectangle vr = new Rectangle(); Rectangle ir = new Rectangle(); Rectangle tr = new Rectangle(); layoutLabel(tabPlacement, getFontMetrics(), tabIndex, tabPane.getTitleAt(tabIndex), icon, vr, ir, tr, tabIndex == tabPane.getSelectedIndex()); width = tr.union(ir).width; } else width = metrics.stringWidth(tabPane.getTitleAt(tabIndex)); width += insets.left + insets.right; return width; }
panel = new ScrollingPanel(); viewport.setView(panel);
protected LayoutManager createLayoutManager() { if (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) return new TabbedPaneLayout(); else { incrButton = createIncreaseButton(); decrButton = createDecreaseButton(); viewport = new ScrollingViewport(); viewport.setLayout(null); panel = new ScrollingPanel(); viewport.setView(panel); tabPane.add(incrButton); tabPane.add(decrButton); tabPane.add(viewport); currentScrollLocation = 0; decrButton.setEnabled(false); panel.addMouseListener(mouseListener); incrButton.addMouseListener(mouseListener); decrButton.addMouseListener(mouseListener); viewport.setBackground(Color.LIGHT_GRAY); return new TabbedPaneScrollLayout(); } }
currentScrollLocation = 0; decrButton.setEnabled(false); panel.addMouseListener(mouseListener); incrButton.addMouseListener(mouseListener); decrButton.addMouseListener(mouseListener); viewport.setBackground(Color.LIGHT_GRAY);
protected LayoutManager createLayoutManager() { if (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) return new TabbedPaneLayout(); else { incrButton = createIncreaseButton(); decrButton = createDecreaseButton(); viewport = new ScrollingViewport(); viewport.setLayout(null); panel = new ScrollingPanel(); viewport.setView(panel); tabPane.add(incrButton); tabPane.add(decrButton); tabPane.add(viewport); currentScrollLocation = 0; decrButton.setEnabled(false); panel.addMouseListener(mouseListener); incrButton.addMouseListener(mouseListener); decrButton.addMouseListener(mouseListener); viewport.setBackground(Color.LIGHT_GRAY); return new TabbedPaneScrollLayout(); } }
if (index == lastTabInRun(tabCount, run) + 1) index = lastTabInRun(tabCount, getPreviousTabRun(run)) + 1; return getNextTabIndex(base);
if (base == lastTabInRun(tabCount, run)) index = (run > 0) ? lastTabInRun(tabCount, getPreviousTabRun(run)) + 1 : 0; return index;
protected int getNextTabIndexInRun(int tabCount, int base) { int index = getNextTabIndex(base); int run = getRunForTab(tabCount, base); if (index == lastTabInRun(tabCount, run) + 1) index = lastTabInRun(tabCount, getPreviousTabRun(run)) + 1; return getNextTabIndex(base); }
return getPreviousTabIndex(base);
return index;
protected int getPreviousTabIndexInRun(int tabCount, int base) { int index = getPreviousTabIndex(base); int run = getRunForTab(tabCount, base); if (index == lastTabInRun(tabCount, getPreviousTabRun(run))) index = lastTabInRun(tabCount, run); return getPreviousTabIndex(base); }
return 1;
return 0;
protected int getRunForTab(int tabCount, int tabIndex) { if (runCount == 1 && tabIndex < tabCount && tabIndex >= 0) return 1; for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (last >= tabIndex && first <= tabIndex) return i; } return -1; }
if (pane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Rectangle r = new Rectangle(rects[i]); switch(pane.getTabPlacement()) { case SwingConstants.TOP: case SwingConstants.BOTTOM: r.x -= currentScrollOffset; break; default: r.y -= currentScrollOffset; } return r; }
public Rectangle getTabBounds(JTabbedPane pane, int i) { // Need to re-layout container if tab does not exist. if (i >= rects.length) layoutManager.layoutContainer(pane); return rects[i]; }
return 0;
switch (tabPlacement) { default: case SwingUtilities.TOP: case SwingUtilities.BOTTOM: return 1; case SwingUtilities.LEFT: return (isSelected) ? -1 : 1; case SwingUtilities.RIGHT: return (isSelected) ? 1 : -1; }
protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected) { // No reason to shift. return 0; }
switch (tabPlacement) { default: case SwingUtilities.TOP: return (isSelected) ? -1 : 1; case SwingUtilities.BOTTOM: return (isSelected) ? 1 : -1; case SwingUtilities.LEFT: case SwingUtilities.RIGHT:
protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) { // No reason to shift. return 0; }
}
protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) { // No reason to shift. return 0; }
highlight = UIManager.getColor("TabbedPane.highlight"); lightHighlight = UIManager.getColor("TabbedPane.lightHighlight");
lightHighlight = UIManager.getColor("TabbedPane.highlight"); highlight = UIManager.getColor("TabbedPane.light");
protected void installDefaults() { LookAndFeel.installColorsAndFont(tabPane, "TabbedPane.background", "TabbedPane.foreground", "TabbedPane.font"); tabPane.setOpaque(false); highlight = UIManager.getColor("TabbedPane.highlight"); lightHighlight = UIManager.getColor("TabbedPane.lightHighlight"); shadow = UIManager.getColor("TabbedPane.shadow"); darkShadow = UIManager.getColor("TabbedPane.darkShadow"); focus = UIManager.getColor("TabbedPane.focus"); textIconGap = UIManager.getInt("TabbedPane.textIconGap"); tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay"); tabInsets = UIManager.getInsets("TabbedPane.tabInsets"); selectedTabPadInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabPadInsets"); tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets"); contentBorderInsets = UIManager.getInsets("TabbedPane.tabbedPaneContentBorderInsets"); tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque"); calcRect = new Rectangle(); tabRuns = new int[10]; tabAreaRect = new Rectangle(); contentRect = new Rectangle(); }
selectedTabPadInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabPadInsets");
selectedTabPadInsets = UIManager.getInsets("TabbedPane.selectedTabPadInsets");
protected void installDefaults() { LookAndFeel.installColorsAndFont(tabPane, "TabbedPane.background", "TabbedPane.foreground", "TabbedPane.font"); tabPane.setOpaque(false); highlight = UIManager.getColor("TabbedPane.highlight"); lightHighlight = UIManager.getColor("TabbedPane.lightHighlight"); shadow = UIManager.getColor("TabbedPane.shadow"); darkShadow = UIManager.getColor("TabbedPane.darkShadow"); focus = UIManager.getColor("TabbedPane.focus"); textIconGap = UIManager.getInt("TabbedPane.textIconGap"); tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay"); tabInsets = UIManager.getInsets("TabbedPane.tabInsets"); selectedTabPadInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabPadInsets"); tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets"); contentBorderInsets = UIManager.getInsets("TabbedPane.tabbedPaneContentBorderInsets"); tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque"); calcRect = new Rectangle(); tabRuns = new int[10]; tabAreaRect = new Rectangle(); contentRect = new Rectangle(); }
contentBorderInsets = UIManager.getInsets("TabbedPane.tabbedPaneContentBorderInsets");
contentBorderInsets = UIManager.getInsets("TabbedPane.contentBorderInsets");
protected void installDefaults() { LookAndFeel.installColorsAndFont(tabPane, "TabbedPane.background", "TabbedPane.foreground", "TabbedPane.font"); tabPane.setOpaque(false); highlight = UIManager.getColor("TabbedPane.highlight"); lightHighlight = UIManager.getColor("TabbedPane.lightHighlight"); shadow = UIManager.getColor("TabbedPane.shadow"); darkShadow = UIManager.getColor("TabbedPane.darkShadow"); focus = UIManager.getColor("TabbedPane.focus"); textIconGap = UIManager.getInt("TabbedPane.textIconGap"); tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay"); tabInsets = UIManager.getInsets("TabbedPane.tabInsets"); selectedTabPadInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabPadInsets"); tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets"); contentBorderInsets = UIManager.getInsets("TabbedPane.tabbedPaneContentBorderInsets"); tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque"); calcRect = new Rectangle(); tabRuns = new int[10]; tabAreaRect = new Rectangle(); contentRect = new Rectangle(); }
selectedColor = UIManager.getColor("TabbedPane.contentAreaColor"); if (selectedColor == null) selectedColor = UIManager.getColor("control");
protected void installDefaults() { LookAndFeel.installColorsAndFont(tabPane, "TabbedPane.background", "TabbedPane.foreground", "TabbedPane.font"); tabPane.setOpaque(false); highlight = UIManager.getColor("TabbedPane.highlight"); lightHighlight = UIManager.getColor("TabbedPane.lightHighlight"); shadow = UIManager.getColor("TabbedPane.shadow"); darkShadow = UIManager.getColor("TabbedPane.darkShadow"); focus = UIManager.getColor("TabbedPane.focus"); textIconGap = UIManager.getInt("TabbedPane.textIconGap"); tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay"); tabInsets = UIManager.getInsets("TabbedPane.tabInsets"); selectedTabPadInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabPadInsets"); tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets"); contentBorderInsets = UIManager.getInsets("TabbedPane.tabbedPaneContentBorderInsets"); tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque"); calcRect = new Rectangle(); tabRuns = new int[10]; tabAreaRect = new Rectangle(); contentRect = new Rectangle(); }
throws NotImplementedException
protected void installKeyboardActions() throws NotImplementedException { // FIXME: Implement. }
InputMap keyMap = (InputMap) UIManager.get("TabbedPane.focusInputMap"); SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, keyMap); keyMap = (InputMap) UIManager.get("TabbedPane.ancestorInputMap"); SwingUtilities .replaceUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, keyMap); ActionMap map = getActionMap(); SwingUtilities.replaceUIActionMap(tabPane, map);
protected void installKeyboardActions() throws NotImplementedException { // FIXME: Implement. }
SwingUtilities.layoutCompoundLabel(metrics, title, icon,
textRect.x = 0; textRect.y = 0; textRect.width = 0; textRect.height = 0; iconRect.x = 0; iconRect.y = 0; iconRect.width = 0; iconRect.height = 0; SwingUtilities.layoutCompoundLabel(tabPane, metrics, title, icon,
protected void layoutLabel(int tabPlacement, FontMetrics metrics, int tabIndex, String title, Icon icon, Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected) { SwingUtilities.layoutCompoundLabel(metrics, title, icon, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.RIGHT, tabRect, iconRect, textRect, textIconGap); int shiftX = getTabLabelShiftX(tabPlacement, tabIndex, isSelected); int shiftY = getTabLabelShiftY(tabPlacement, tabIndex, isSelected); iconRect.x += shiftX; iconRect.y += shiftY; textRect.x += shiftX; textRect.y += shiftY; }
(tabPlacement == SwingConstants.RIGHT) ? true : false);
(tabPlacement == SwingConstants.TOP) ? direction == SwingConstants.NORTH : direction == SwingConstants.SOUTH);
protected void navigateSelectedTab(int direction) { int tabPlacement = tabPane.getTabPlacement(); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { if (direction == SwingConstants.WEST) selectPreviousTabInRun(tabPane.getSelectedIndex()); else if (direction == SwingConstants.EAST) selectNextTabInRun(tabPane.getSelectedIndex()); else { int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(), tabPane.getSelectedIndex(), (tabPlacement == SwingConstants.RIGHT) ? true : false); selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(), offset); } } if (tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT) { if (direction == SwingConstants.NORTH) selectPreviousTabInRun(tabPane.getSelectedIndex()); else if (direction == SwingConstants.SOUTH) selectNextTabInRun(tabPane.getSelectedIndex()); else { int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(), tabPane.getSelectedIndex(), (tabPlacement == SwingConstants.RIGHT) ? true : false); selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(), offset); } } }
(tabPlacement == SwingConstants.RIGHT) ? true : false);
(tabPlacement == SwingConstants.LEFT) ? direction == SwingConstants.WEST : direction == SwingConstants.EAST);
protected void navigateSelectedTab(int direction) { int tabPlacement = tabPane.getTabPlacement(); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { if (direction == SwingConstants.WEST) selectPreviousTabInRun(tabPane.getSelectedIndex()); else if (direction == SwingConstants.EAST) selectNextTabInRun(tabPane.getSelectedIndex()); else { int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(), tabPane.getSelectedIndex(), (tabPlacement == SwingConstants.RIGHT) ? true : false); selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(), offset); } } if (tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT) { if (direction == SwingConstants.NORTH) selectPreviousTabInRun(tabPane.getSelectedIndex()); else if (direction == SwingConstants.SOUTH) selectNextTabInRun(tabPane.getSelectedIndex()); else { int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(), tabPane.getSelectedIndex(), (tabPlacement == SwingConstants.RIGHT) ? true : false); selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(), offset); } } }
paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex()); paintContentBorder(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
{ g.setColor(highlight); g.fillRect(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, tabAreaRect.height); paintTabArea(g, tabPlacement, index); } paintContentBorder(g, tabPlacement, index);
public void paint(Graphics g, JComponent c) { if (!tabPane.isValid()) tabPane.validate(); if (tabPane.getTabCount() == 0) return; if (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex()); paintContentBorder(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex()); }
Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) { int width = tabPane.getWidth(); int height = tabPane.getHeight(); Insets insets = tabPane.getInsets(); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); // Calculate coordinates of content area. int x = insets.left; int y = insets.top; int w = width - insets.left - insets.right; int h = height - insets.top - insets.bottom; switch (tabPlacement) { case LEFT: x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); w -= x - insets.left; break; case RIGHT: w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); break; case BOTTOM: h -= calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); break; case TOP: default: y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); h -= y - insets.top; } // Fill background if necessary. if (tabPane.isOpaque()) { Color bg = UIManager.getColor("TabbedPane.contentAreaColor"); g.setColor(bg); g.fillRect(x, y, w, h); } // Paint border. paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h); paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h); paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h); paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h); }
int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width;
int startgap = rects[selectedIndex].x - currentScrollOffset; int endgap = rects[selectedIndex].x + rects[selectedIndex].width - currentScrollOffset;
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.BOTTOM) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.setColor(shadow); g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1); g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, startgap - diff, y + h); g.drawLine(endgap - diff, y + h, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } g.setColor(saved); }
int diff = 0; if (tabPlacement == SwingConstants.BOTTOM) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
if (tabPlacement == SwingConstants.BOTTOM && startgap >= 0)
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.BOTTOM) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.setColor(shadow); g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1); g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, startgap - diff, y + h); g.drawLine(endgap - diff, y + h, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } g.setColor(saved); }
Point p = findPointForIndex(currentScrollLocation); diff = p.x; }
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.BOTTOM) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.setColor(shadow); g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1); g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, startgap - diff, y + h); g.drawLine(endgap - diff, y + h, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } g.setColor(saved); }
g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1); g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1);
g.drawLine(x + 1, y + h - 2, startgap, y + h - 2); g.drawLine(endgap, y + h - 2, x + w - 2, y + h - 2);
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.BOTTOM) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.setColor(shadow); g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1); g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, startgap - diff, y + h); g.drawLine(endgap - diff, y + h, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } g.setColor(saved); }
g.drawLine(x, y + h, startgap - diff, y + h); g.drawLine(endgap - diff, y + h, x + w, y + h);
g.drawLine(x, y + h - 1, startgap , y + h - 1); g.drawLine(endgap, y + h - 1, x + w - 1, y + h - 1); g.setColor(selectedColor); g.drawLine(startgap, y + h - 1, endgap - 1, y + h - 1); g.drawLine(startgap, y + h - 2, endgap - 1, y + h - 2);
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.BOTTOM) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.setColor(shadow); g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1); g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, startgap - diff, y + h); g.drawLine(endgap - diff, y + h, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } g.setColor(saved); }
g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
g.drawLine(x + 1, y + h - 2, x + w - 1, y + h - 2);
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.BOTTOM) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.setColor(shadow); g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1); g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, startgap - diff, y + h); g.drawLine(endgap - diff, y + h, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } g.setColor(saved); }
g.drawLine(x, y + h, x + w, y + h);
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.BOTTOM) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.setColor(shadow); g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1); g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, startgap - diff, y + h); g.drawLine(endgap - diff, y + h, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } g.setColor(saved); }
g.setColor(selectedColor); g.drawLine(x + 1, y + h - 3, x + w - 2, y + h - 3);
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.BOTTOM) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.setColor(shadow); g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1); g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, startgap - diff, y + h); g.drawLine(endgap - diff, y + h, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } g.setColor(saved); }
int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height;
int startgap = rects[selectedIndex].y - currentScrollOffset; int endgap = rects[selectedIndex].y + rects[selectedIndex].height - currentScrollOffset;
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); g.setColor(lightHighlight); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.LEFT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.drawLine(x, y, x, startgap - diff); g.drawLine(x, endgap - diff, x, y + h); } else g.drawLine(x, y, x, y + h); g.setColor(saved); }
int diff = 0;
if (tabPlacement == SwingConstants.LEFT && startgap >= 0) { g.drawLine(x, y, x, startgap); g.drawLine(x, endgap, x, y + h - 1);
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); g.setColor(lightHighlight); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.LEFT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.drawLine(x, y, x, startgap - diff); g.drawLine(x, endgap - diff, x, y + h); } else g.drawLine(x, y, x, y + h); g.setColor(saved); }
if (tabPlacement == SwingConstants.LEFT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.drawLine(x, y, x, startgap - diff); g.drawLine(x, endgap - diff, x, y + h);
g.setColor(selectedColor); g.drawLine(x, startgap, x, endgap - 1);
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); g.setColor(lightHighlight); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.LEFT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.drawLine(x, y, x, startgap - diff); g.drawLine(x, endgap - diff, x, y + h); } else g.drawLine(x, y, x, y + h); g.setColor(saved); }
g.drawLine(x, y, x, y + h);
g.drawLine(x, y, x, y + h - 1); g.setColor(selectedColor); g.drawLine(x + 1, y + 1, x + 1, y + h - 4);
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); g.setColor(lightHighlight); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.LEFT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.drawLine(x, y, x, startgap - diff); g.drawLine(x, endgap - diff, x, y + h); } else g.drawLine(x, y, x, y + h); g.setColor(saved); }
int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height;
int startgap = rects[selectedIndex].y - currentScrollOffset; int endgap = rects[selectedIndex].y + rects[selectedIndex].height - currentScrollOffset;
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.RIGHT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff); g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, startgap - diff); g.drawLine(x + w, endgap - diff, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); } g.setColor(saved); }
int diff = 0; if (tabPlacement == SwingConstants.RIGHT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
if (tabPlacement == SwingConstants.RIGHT && startgap >= 0)
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.RIGHT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff); g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, startgap - diff); g.drawLine(x + w, endgap - diff, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); } g.setColor(saved); }
Point p = findPointForIndex(currentScrollLocation); diff = p.y; }
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.RIGHT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff); g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, startgap - diff); g.drawLine(x + w, endgap - diff, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); } g.setColor(saved); }
g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff); g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1);
g.drawLine(x + w - 2, y + 1, x + w - 2, startgap); g.drawLine(x + w - 2, endgap, x + w - 2, y + h - 2);
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.RIGHT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff); g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, startgap - diff); g.drawLine(x + w, endgap - diff, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); } g.setColor(saved); }
g.drawLine(x + w, y, x + w, startgap - diff); g.drawLine(x + w, endgap - diff, x + w, y + h);
g.drawLine(x + w - 1, y, x + w - 1, startgap); g.drawLine(x + w - 1, endgap, x + w - 1, y + h - 2); g.setColor(selectedColor); g.drawLine(x + w - 2, startgap, x + w - 2, endgap - 1); g.drawLine(x + w - 1, startgap, x + w - 1, endgap - 1);
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.RIGHT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff); g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, startgap - diff); g.drawLine(x + w, endgap - diff, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); } g.setColor(saved); }
g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.RIGHT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff); g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, startgap - diff); g.drawLine(x + w, endgap - diff, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); } g.setColor(saved); }
g.drawLine(x + w, y, x + w, y + h);
g.drawLine(x + w - 1, y, x + w - 1, y + h - 2);
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.RIGHT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff); g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, startgap - diff); g.drawLine(x + w, endgap - diff, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); } g.setColor(saved); }
g.setColor(selectedColor); g.drawLine(x + w - 3, y + 1, x + w - 3, y + h - 4);
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); int startgap = rects[selectedIndex].y; int endgap = rects[selectedIndex].y + rects[selectedIndex].height; int diff = 0; if (tabPlacement == SwingConstants.RIGHT) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.y; } g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff); g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, startgap - diff); g.drawLine(x + w, endgap - diff, x + w, y + h); } else { g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); } g.setColor(saved); }
int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width;
int startgap = rects[selectedIndex].x - currentScrollOffset; int endgap = rects[selectedIndex].x + rects[selectedIndex].width - currentScrollOffset;
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); g.setColor(lightHighlight); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.TOP) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.drawLine(x, y, startgap - diff, y); g.drawLine(endgap - diff, y, x + w, y); } else g.drawLine(x, y, x + w, y); g.setColor(saved); }
int diff = 0;
if (tabPlacement == SwingConstants.TOP && startgap >= 0) { g.drawLine(x, y, startgap, y); g.drawLine(endgap, y, x + w - 1, y);
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); g.setColor(lightHighlight); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.TOP) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.drawLine(x, y, startgap - diff, y); g.drawLine(endgap - diff, y, x + w, y); } else g.drawLine(x, y, x + w, y); g.setColor(saved); }
if (tabPlacement == SwingConstants.TOP) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.drawLine(x, y, startgap - diff, y); g.drawLine(endgap - diff, y, x + w, y);
g.setColor(selectedColor); g.drawLine(startgap, y, endgap - 1, y);
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); g.setColor(lightHighlight); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.TOP) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.drawLine(x, y, startgap - diff, y); g.drawLine(endgap - diff, y, x + w, y); } else g.drawLine(x, y, x + w, y); g.setColor(saved); }
g.setColor(selectedColor); g.drawLine(x, y + 1, x + w - 1, y + 1); g.drawLine(x, y + 2, x + w - 1, y + 2);
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { Color saved = g.getColor(); g.setColor(lightHighlight); int startgap = rects[selectedIndex].x; int endgap = rects[selectedIndex].x + rects[selectedIndex].width; int diff = 0; if (tabPlacement == SwingConstants.TOP) { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { Point p = findPointForIndex(currentScrollLocation); diff = p.x; } g.drawLine(x, y, startgap - diff, y); g.drawLine(endgap - diff, y, x + w, y); } else g.drawLine(x, y, x + w, y); g.setColor(saved); }
Rectangle ir = new Rectangle(); Rectangle tr = new Rectangle(); boolean isScroll = tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT;
protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) { Rectangle ir = new Rectangle(); Rectangle tr = new Rectangle(); boolean isScroll = tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT; // Please note: the ordering of the painting is important. // we WANT to paint the outermost run first and then work our way in. int tabCount = tabPane.getTabCount(); for (int i = runCount - 1; i >= 0; --i) { int start = tabRuns[i]; int next; if (i == runCount - 1) next = tabRuns[0]; else next = tabRuns[i + 1]; int end = next != 0 ? next - 1 : tabCount - 1; for (int j = start; j <= end; ++j) { if (j != selectedIndex) { paintTab(g, tabPlacement, rects, j, ir, tr); } } } // Paint selected tab in front of every other tab. if (selectedIndex >= 0) paintTab(g, tabPlacement, rects, selectedIndex, ir, tr); }
paintTab(g, tabPlacement, rects, j, ir, tr);
paintTab(g, tabPlacement, rects, j, tempIconRect, tempTextRect);
protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) { Rectangle ir = new Rectangle(); Rectangle tr = new Rectangle(); boolean isScroll = tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT; // Please note: the ordering of the painting is important. // we WANT to paint the outermost run first and then work our way in. int tabCount = tabPane.getTabCount(); for (int i = runCount - 1; i >= 0; --i) { int start = tabRuns[i]; int next; if (i == runCount - 1) next = tabRuns[0]; else next = tabRuns[i + 1]; int end = next != 0 ? next - 1 : tabCount - 1; for (int j = start; j <= end; ++j) { if (j != selectedIndex) { paintTab(g, tabPlacement, rects, j, ir, tr); } } } // Paint selected tab in front of every other tab. if (selectedIndex >= 0) paintTab(g, tabPlacement, rects, selectedIndex, ir, tr); }
paintTab(g, tabPlacement, rects, selectedIndex, ir, tr);
paintTab(g, tabPlacement, rects, selectedIndex, tempIconRect, tempTextRect);
protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) { Rectangle ir = new Rectangle(); Rectangle tr = new Rectangle(); boolean isScroll = tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT; // Please note: the ordering of the painting is important. // we WANT to paint the outermost run first and then work our way in. int tabCount = tabPane.getTabCount(); for (int i = runCount - 1; i >= 0; --i) { int start = tabRuns[i]; int next; if (i == runCount - 1) next = tabRuns[0]; else next = tabRuns[i + 1]; int end = next != 0 ? next - 1 : tabCount - 1; for (int j = start; j <= end; ++j) { if (j != selectedIndex) { paintTab(g, tabPlacement, rects, j, ir, tr); } } } // Paint selected tab in front of every other tab. if (selectedIndex >= 0) paintTab(g, tabPlacement, rects, selectedIndex, ir, tr); }
g.setColor(Color.LIGHT_GRAY);
g.setColor(selectedColor);
protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { Color saved = g.getColor(); if (isSelected) g.setColor(Color.LIGHT_GRAY); else { Color bg = tabPane.getBackgroundAt(tabIndex); if (bg == null) bg = Color.GRAY; g.setColor(bg); } g.fillRect(x, y, w, h); g.setColor(saved); }
bg = Color.GRAY;
bg = Color.LIGHT_GRAY;
protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { Color saved = g.getColor(); if (isSelected) g.setColor(Color.LIGHT_GRAY); else { Color bg = tabPane.getBackgroundAt(tabIndex); if (bg == null) bg = Color.GRAY; g.setColor(bg); } g.fillRect(x, y, w, h); g.setColor(saved); }
g.fillRect(x, y, w, h);
switch (tabPlacement) { case SwingConstants.TOP: g.fillRect(x + 1, y + 1, w - 1, h - 1); break; case SwingConstants.BOTTOM: g.fillRect(x, y, w - 1, h - 1); break; case SwingConstants.LEFT: g.fillRect(x + 1, y + 1, w - 1, h - 2); break; case SwingConstants.RIGHT: g.fillRect(x, y + 1, w - 1, h - 2); break; }
protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { Color saved = g.getColor(); if (isSelected) g.setColor(Color.LIGHT_GRAY); else { Color bg = tabPane.getBackgroundAt(tabIndex); if (bg == null) bg = Color.GRAY; g.setColor(bg); } g.fillRect(x, y, w, h); g.setColor(saved); }
if (! isSelected || tabPlacement != SwingConstants.TOP)
switch (tabPlacement)
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { Color saved = g.getColor(); if (! isSelected || tabPlacement != SwingConstants.TOP) { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } if (! isSelected || tabPlacement != SwingConstants.LEFT) { g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); } if (! isSelected || tabPlacement != SwingConstants.RIGHT) { g.setColor(lightHighlight); g.drawLine(x, y, x, y + h); } if (! isSelected || tabPlacement != SwingConstants.BOTTOM) { g.setColor(lightHighlight); g.drawLine(x, y, x + w, y); } g.setColor(saved); }
g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
g.drawLine(x + w - 2, y + 2, x + w - 2, y + h);
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { Color saved = g.getColor(); if (! isSelected || tabPlacement != SwingConstants.TOP) { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } if (! isSelected || tabPlacement != SwingConstants.LEFT) { g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); } if (! isSelected || tabPlacement != SwingConstants.RIGHT) { g.setColor(lightHighlight); g.drawLine(x, y, x, y + h); } if (! isSelected || tabPlacement != SwingConstants.BOTTOM) { g.setColor(lightHighlight); g.drawLine(x, y, x + w, y); } g.setColor(saved); }
g.drawLine(x, y + h, x + w, y + h); }
g.drawLine(x + w - 1, y + 2, x + w - 1, y + h); g.drawLine(x + w - 2, y + 1, x + w - 1, y + 2); g.setColor(lightHighlight); g.drawLine(x, y + 3, x, y + h); g.drawLine(x + 3, y, x + w - 3, y); g.drawLine(x, y + 2, x + 2, y); break; case SwingConstants.LEFT: g.setColor(lightHighlight); g.drawLine(x + 3, y, x + w - 1, y); g.drawLine(x + 2, y, x, y + 2); g.drawLine(x, y + 3, x, y + h - 4); g.drawLine(x, y + h - 3, x + 1, y + h - 2);
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { Color saved = g.getColor(); if (! isSelected || tabPlacement != SwingConstants.TOP) { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } if (! isSelected || tabPlacement != SwingConstants.LEFT) { g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); } if (! isSelected || tabPlacement != SwingConstants.RIGHT) { g.setColor(lightHighlight); g.drawLine(x, y, x, y + h); } if (! isSelected || tabPlacement != SwingConstants.BOTTOM) { g.setColor(lightHighlight); g.drawLine(x, y, x + w, y); } g.setColor(saved); }
if (! isSelected || tabPlacement != SwingConstants.LEFT) {
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { Color saved = g.getColor(); if (! isSelected || tabPlacement != SwingConstants.TOP) { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } if (! isSelected || tabPlacement != SwingConstants.LEFT) { g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); } if (! isSelected || tabPlacement != SwingConstants.RIGHT) { g.setColor(lightHighlight); g.drawLine(x, y, x, y + h); } if (! isSelected || tabPlacement != SwingConstants.BOTTOM) { g.setColor(lightHighlight); g.drawLine(x, y, x + w, y); } g.setColor(saved); }
g.drawLine(x + w, y, x + w, y + h);
g.drawLine(x + 2, y + h - 1, x + w - 1, y + h - 1);
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { Color saved = g.getColor(); if (! isSelected || tabPlacement != SwingConstants.TOP) { g.setColor(shadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); g.setColor(darkShadow); g.drawLine(x, y + h, x + w, y + h); } if (! isSelected || tabPlacement != SwingConstants.LEFT) { g.setColor(darkShadow); g.drawLine(x + w, y, x + w, y + h); g.setColor(shadow); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); } if (! isSelected || tabPlacement != SwingConstants.RIGHT) { g.setColor(lightHighlight); g.drawLine(x, y, x, y + h); } if (! isSelected || tabPlacement != SwingConstants.BOTTOM) { g.setColor(lightHighlight); g.drawLine(x, y, x + w, y); } g.setColor(saved); }