swing - Controlling Color in Java Tabbed Pane -


i have been going nuts trying figure out.

i trying elimenate light blue background appears in jtabbedpane. i've tried , nothing seems work.

below code. if run it, show tab, when selected light blue background , thing blue border @ top. want control color. how?

import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.plaf.coloruiresource; public class main extends jframe {   jtabbedpane tab=new jtabbedpane();   public main() {      setsize(300,300);      settitle("test tab pane");      tab.add("first",new mypanel("first"));      tab.add("second",new mypanel("second"));      tab.add("third",new mypanel("third"));      tab.add("fourth",new mypanel("fourth"));      tab.addchangelistener(new changetab());      getcontentpane().add(tab,borderlayout.center);      setvisible(true);      for(int i=0;i<tab.gettabcount();i++){           if(i != tab.getselectedindex())             tab.setbackgroundat(i,color.orange);             tab.setforeground(color.black);      }      tab.setopaque(true);      uimanager.put("tabbedpane.contentareacolor ",coloruiresource.green);      uimanager.put("tabbedpane.selected",coloruiresource.green);      uimanager.put("tabbedpane.background",coloruiresource.green);      uimanager.put("tabbedpane.shadow",coloruiresource.green);   }    public static void main(string[] args) {     main main = new main();   }    class changetab implements changelistener{     public void statechanged(changeevent e){         tab.validate();         system.out.println(tab.getselectedindex());         for(int i=0;i<tab.gettabcount();i++){           if(i != tab.getselectedindex())             tab.setbackgroundat(i,color.orange);         }      }   }    class mypanel extends jpanel{     public mypanel(string str){        add(new jlabel(str));     }   }  } 

i used example code, , worked me moving calls uimanager.put() point executed before jtabbedpane constructor executed.

public class main extends jframe {     jtabbedpane tab;      public main() {        // ... other stuff        uimanager.put("tabbedpane.contentareacolor ",coloruiresource.green);        uimanager.put("tabbedpane.selected",coloruiresource.green);        uimanager.put("tabbedpane.background",coloruiresource.green);        uimanager.put("tabbedpane.shadow",coloruiresource.green);         // construct tabbed pane        tab=new jtabbedpane();         // ... other stuff  } 

there's other properties available (for metal l&f, @ least):

uimanager.put("tabbedpane.bordercolor", color.red); uimanager.put("tabbedpane.darkshadow", coloruiresource.red); uimanager.put("tabbedpane.light", coloruiresource.red); uimanager.put("tabbedpane.highlight", coloruiresource.red); uimanager.put("tabbedpane.focus", coloruiresource.red); uimanager.put("tabbedpane.unselectedbackground", coloruiresource.red); uimanager.put("tabbedpane.selecthighlight", coloruiresource.red); uimanager.put("tabbedpane.tabareabackground", coloruiresource.red); uimanager.put("tabbedpane.borderhightlightcolor", coloruiresource.red); 

these let control of colours in tab area.

i found these settings there still small blue-ish grey border around content. have searched how set colour no avail. solution find rid of was:

uimanager.put("tabbedpane.contentborderinsets", new insets(0, 0, 0, 0)); 

which sub-optimal solution.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -