Petter
Petter

Reputation: 783

Remove JTabbedPane border/divider in Nimbus Look and Feel

I use the Nimbus L&F, and I'm trying to remove the border shown on the picture below, as well as centering the tabs on my screen, similar to the default Mac OS look and feel. But I have still not had any success.

Help anyone?

http://bildr.no/image/cUJBdW94.jpeg

Upvotes: 1

Views: 806

Answers (2)

Wesos de Queso
Wesos de Queso

Reputation: 1572

This removed those borders for me, what i wanted was to change it style but whatever...

tabbedPane.setUI(new javax.swing.plaf.basic.BasicTabbedPaneUI() {
          protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {};
    });

Upvotes: 0

Paul Samsotha
Paul Samsotha

Reputation: 209132

Not sure why you would even want to do this, but what you want to do is modify the defaults. You can see Nimbus Defaults for all of the default settings. If you scroll down the page, you will see all the defaults for TabbedPanes.

enter image description here

You can see all the painting of these default properties are done by a Painter. You can set the painter to null, so it won't paint anything.

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    if ("Nimbus".equals(info.getName())) {
        UIManager.setLookAndFeel(info.getClassName());
        UIManager.getLookAndFeelDefaults().put(
                "TabbedPane:TabbedPaneTabArea[Disabled].backgroundPainter", null);
        UIManager.getLookAndFeelDefaults().put(
                "TabbedPane:TabbedPaneTabArea[Enabled+MouseOver].backgroundPainter", null);
        UIManager.getLookAndFeelDefaults().put(
                "TabbedPane:TabbedPaneTabArea[Enabled+Pressed].backgroundPainter", null);
        UIManager.getLookAndFeelDefaults().put(
                "TabbedPane:TabbedPaneTabArea[Enabled].backgroundPainter", null);
        break;
    }
}

enter image description here

Upvotes: 1

Related Questions