@Override
public void paint(Graphics2D graphics) {
TabPane tabPane = (TabPane)getComponent();
Bounds tabPaneBounds = tabPane.getBounds();
// Call the base class to paint the background
super.paint(graphics);
graphics.setStroke(new BasicStroke());
// Paint the content background and border
int x = 0;
int y = 0;
int width = 0;
int height = 0;
Orientation tabOrientation = tabPane.getTabOrientation();
switch (tabOrientation) {
case HORIZONTAL: {
x = 0;
y = Math.max(buttonPanorama.getY() + buttonPanorama.getHeight() - 1, 0);
width = tabPaneBounds.width;
height = Math.max(tabPaneBounds.height - y, 0);
break;
}
case VERTICAL: {
x = Math.max(buttonPanorama.getX() + buttonPanorama.getWidth() - 1, 0);
y = 0;
width = Math.max(tabPaneBounds.width - x, 0);
height = tabPaneBounds.height;
break;
}
}
Bounds contentBounds = new Bounds(x, y, width, height);
if (!contentBounds.isEmpty()) {
// If a tab is selected, paint the active background color; otherwise,
// paint the inactive background color
int selectedIndex = tabPane.getSelectedIndex();
graphics.setPaint((selectedIndex == -1) ? inactiveTabColor : activeTabColor);
graphics.fillRect(contentBounds.x, contentBounds.y,