Set the Background Color for JTabbedPane

后端 未结 6 852
傲寒
傲寒 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:17

    Sorry for my english.

    I tried resolve this problem 2 days.. There are "work around" solve.

    Need set tab component. And then set color for this component.

    /*
      ...
      Setting LAF Nimbus
      ...
    */
    
    JTabbedPane tp = new JTabbedPane();
    
    /*
       ...
       add tabs in TabbedPane
       ...
    */
    

    then for specified tabs need do:

            JLabel title = new JLabel(tp.getTitleAt(tabIndex));
            title.setForeground(Color.RED);
            tp.setTabComponentAt(tabIndex, title);
    

    OMG!! its work!

提交回复
热议问题