Set the Background Color for JTabbedPane

后端 未结 6 854
傲寒
傲寒 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 13:58

    There are a few different things you can do, depending upon how much control you want over the exact color. The easiest way is to change some of the properties in the UIManager to change the colors that Nimbus derives its other colors from. I played around a little with your code, and found that if I put the following code after the call to UIManager.setLookAndFeel(), it would approximate the red-on-black look you attempted in your example:

         UIManager.put("nimbusBase", new ColorUIResource(0, 0, 0));
         UIManager.put("textForeground", new ColorUIResource(255, 0, 0));
    

    I'll leave it to you to experiment. For more information to experiment with, there is a good article on configuring Nimbus here. Be sure you look at his link titled "Nimbus UIDefaults Properties List". Outside of just massaging the colors to something similar to what you want, you'll have to start doing messy things like implementing Painter classes that do custom painting.

提交回复
热议问题