final Style tabbedPaneStyle, final int cellOffsetX,
final int cellOffsetY, final Dimension cellsPreferredSize,
final Dimension contentPaneSize) {
Label cell = new Label(text) {
public void paint(Graphics g) {
int tPBorder = tp.getTabbedPaneBorderWidth();
int focusMarkWidth = tPBorder * 2;
int tabP = tp.getTabPlacement();
// Initialize forground colors before calling to super.paint()
if (isSelected && cellHasFocus) {
focusMarkWidth = tPBorder * 3;
this.getStyle().setFgSelectionColor(cellStyle.getFgSelectionColor());
} else {
this.getStyle().setFgColor(cellStyle.getFgColor());
}
super.paint(g);
if (!isSelected) {
g.setColor(0);
g.fillRect(getX(), getY(), getWidth(), getHeight(), (byte) 0x2f);
}
// coloring back the focus mark line
g.setColor(getStyle().getFgColor());
if (tabP == tp.TOP || tabP == tp.BOTTOM) {
if (tabP == tp.TOP) {
if (isSelected) {
g.fillRect(getX(), getY() + tPBorder, getWidth(), focusMarkWidth);// north
}
g.setColor(tabbedPaneStyle.getFgColor());
g.fillRect(getX(), getY(), getWidth(), tPBorder);//north line
g.fillRect(getX(), getY(), tPBorder, getHeight());// west line
} else {
if (isSelected) {
g.fillRect(getX(), getY() + getHeight() - focusMarkWidth, getWidth(), focusMarkWidth);// south
}
g.setColor(tabbedPaneStyle.getFgColor());
g.fillRect(getX(), getY() + getHeight() - tPBorder, getWidth(), tPBorder);//south line
g.fillRect(getX(), getY(), tPBorder, getHeight());// west line
}
int x = getX() - cellOffsetX + getWidth();
if (x == contentPaneSize.getWidth()) {
g.fillRect(x + cellOffsetX - tPBorder, getY(), tPBorder, getHeight());// east line
}
if (cellsPreferredSize.getWidth() < contentPaneSize.getWidth() && (getX() + getWidth() == cellsPreferredSize.getWidth())) {
g.fillRect(getX() + getWidth() - tPBorder, getY(), tPBorder, getHeight());
}
} else { // LEFT or RIGHT
if (isSelected) {
g.fillRect(getX(), getY() + tPBorder, getWidth(), focusMarkWidth);// north
}
g.setColor(tabbedPaneStyle.getFgColor());
g.fillRect(getX(), getY(), getWidth(), tPBorder);
int y = getY() - cellOffsetY + getHeight();
if (y == contentPaneSize.getHeight()) {
g.fillRect(getX(), y + cellOffsetY - tPBorder, getWidth(), tPBorder);
}
if (cellsPreferredSize.getHeight() < contentPaneSize.getHeight() && (getY() + getHeight() == cellsPreferredSize.getHeight())) {
g.fillRect(getX(), getY() + getHeight() - tPBorder, getWidth(), tPBorder);//south line
}
if (tabP == tp.LEFT) {
g.fillRect(getX(), getY(), tPBorder, getHeight());// west border
} else {
g.fillRect(getX() + getWidth() - tPBorder, getY(), tPBorder, getHeight());// east border
}
}
}
};
cell.setCellRenderer(true);
cell.getStyle().setBorder(null);
cell.setIcon(icon);
updateCellLook(tp, (Component) cell, isSelected);
if (isSelected) {
cellStyle.setBgSelectionColor(cellStyle.getBgColor());
}
cell.setAlignment(Label.CENTER);
return cell;
}