Set the Background Color for JTabbedPane

后端 未结 6 900
傲寒
傲寒 2021-01-06 13:20

I am using Nimbus Look and feel. I needs to change the Background color and foreground color of the tab in JTabbedPane but the color doesn\'t set in JTabbedPane. I tried set

6条回答
  •  误落风尘
    2021-01-06 14:06

    Actually not true

    new JTabbedPane().setUI(new YourUI());
    

    and then you create your simple UI

    public class YourUI extends BasicTabbedPaneUI{
    
    .....
    
    private class ScrollableTabPanel extends JPanel implements UIResource {
    public ScrollableTabPanel() {
        setLayout(null);
    }
    
    public void paintComponent(Graphics g) {
    
    super.paintComponent(g);
    
    g.setColor(Color.red);
    g.fillRect(tabPane.getBounds());            
    
            }
        }
    
    ....
    
    }
    

    Jan Cajthaml

    There is how it should look like (don't mind the QuadSpline tabs and close bars thats another add-ons of my UI implementation), my reputation here is none so there is a link to the image

    http://a5.sphotos.ak.fbcdn.net/hphotos-ak-ash3/166028_2974620064454_896181702_n.jpg

提交回复
热议问题