I am creating my own custom JTabbedPane
object, with a simple little class that extends JTabbedPane
. I have gotten a fair amount of this done, but recently found a problem, that being that the Title text for a tab does not auto align to the center of the Tab. And I want it to. Here is what it looks like:
As I said, it's just an extension of JTabbedArea
, like so:
private static final long serialVersionUID = 1L;
private String name;
private final int width = 150, height = 50;
public ColoredTabs(String paneName, int tabPlacement, String[] names, Color[] colors, JComponent[] components){
super(tabPlacement);
this.name = paneName;
if(names.length != components.length || names.length != colors.length || components.length != colors.length){
throw new IllegalArgumentException("The arguments for COMPONENTS, COLORS, and NAMES do not match up for '"+this.name+"'...");
}
setFont(Resources.getFont());
setBackground(Color.YELLOW);
for(int i = 0; i < names.length; i++){
addTab(names[i], components[i]);
setBackgroundAt(i, colors[i]);
setIconAt(i, new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB)));
}
}
The reason I go through the trouble of making the BufferedImage is to stretch the area of the Tab, for the ICON, maybe there is a way to center the text on the BufferedImage, any ideas?