1

Issue: Can't change edge around content area of tabbed panel or tabs background color

Tried: Setting panels opaque, changing UIManager defaults, and a few other random things.

enter image description here

Code: https://gist.github.com/DarkGuardsman/b86c542cc168d1c792a01a4d44dba229

Note: I didn't write all of this code as I'm updating an existing project with interface changes. So keep remarks to the solution and not coding style.

DarkGuardsman
  • 126
  • 4
  • 15
  • Use tabbedPane.setBackgroundAt(). For more details, refer this. http://stackoverflow.com/questions/8752037/how-to-change-background-color-of-jtabbedpane... This might help you. – Jay Patel Jul 27 '16 at 02:42
  • If you look at the source I'm already trying that, but I'll look at the link :) ty – DarkGuardsman Jul 27 '16 at 17:54

1 Answers1

0

I found a solution though I'm pretty sure it's not the best solution. I was originally heading for this before posting. After reading through the UI code I found that it paints a border around the content panel. Overriding the method paintTabBackground which does most of the border solved the issue.

private class TabUI extends BasicTabbedPaneUI
{
    @Override
    protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected ) {
        g.setColor(LauncherFrame.secondaryColor);
        switch(tabPlacement) {
            case LEFT:
                g.fillRect(x+1, y+1, w-1, h-3);
                break;
            case RIGHT:
                g.fillRect(x, y+1, w-2, h-3);
                break;
            case BOTTOM:
                g.fillRect(x+1, y, w-3, h-1);
                break;
            case TOP:
            default:
                g.fillRect(x+1, y+1, w-3, h-1);
        }
    }
}

enter image description here

DarkGuardsman
  • 126
  • 4
  • 15