super.paintIcon(c, g, x, y);
} else
throw new IllegalStateException("Invalid Content Index");
}
};
leftIcon = new CompositeIcon(titleIcon, icon, SwingConstants.LEFT);
// Right Part
Icon rightIcon = new CompositeIcon(maxImgD, closeImgD, SwingConstants.LEFT) {
boolean isSelected;
int count;
public void paintIcon(Component c, Graphics g, int x, int y) {
Component tabComponent = (Component) accessible.getAccessibleChild(0);
isSelected = false;
for (int i = 0, size = tabbedPane.getTabCount(); i < size; i++) {
if (tabbedPane.getComponentAt(i) == tabComponent) {
if (tabbedPane.getSelectedIndex() == i)
isSelected = true;
break;
}
}
count = 0;
super.paintIcon(c, g, x, y);
}
protected void paintIconInternal(Component c, Graphics g, Icon icon, int x, int y, int width, int height, int horizontalOrientation, int verticalOrientation) {
if (count == 0) {
super.paintIconInternal(c, g,
isSelected ? maxImgI : maxImgD,
x, y, width, height, horizontalOrientation, verticalOrientation);
} else if (count == 1) {
super.paintIconInternal(c, g,
isSelected ? closeImgI : closeImgD,
x, y, width, height, horizontalOrientation, verticalOrientation);
}
count = (count + 1) % 2;
}
protected void paint(Component c, Graphics g, Icon icon, int x, int y) {
super.paint(c, g, icon, x, y);
if (count == 0) {
icon1Rec = new Rectangle(x, y, getIconWidth(icon1), getIconHeight(icon1));
} else
icon2Rec = new Rectangle(x, y, getIconWidth(icon2), getIconHeight(icon2));
}
};
contentIcon = new CompositeIcon(leftIcon, rightIcon, SwingConstants.LEFT);
}
return contentIcon;
}