views:

224

answers:

2
UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(207,255,247)));
UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(207,255,247)));
JDesktopPane baTabbedPane = new JDesktopPane();
JInternalFrame iframe = new JInternalFrame("Cheapest To Deliver",true,true,true,true);
iframe.setSize(400,150);
baTabbedPane.add(iframe);

why is my Internal Frame's title background not set on startup?

I've tried setting it on the overall JFrame init but made no difference (By contrast I could change other JFrame ui component look n feel such as MenuItem.background in this location so I thought it might have been because the JInternalFrame was not a top-level component i.e. under a tabbed pane, that maybe it needed changing at some other point, but where?)

Any tips on the correct place to call UIManager.put() for JInternalFrame?

A: 

I think you need to make all calls to UIManager.put before you create any Swing components.

willcodejavaforfood
I did this and added in a change of MenuItem.background colour too but only the MenuItem color changed and not that of the JInternalFrame title background. Is there anything else I need to do to set the JInternal Frame look n feel?
rutherford
Could you post the smallest possible working example that reproduces this problem so I can try it?
willcodejavaforfood
A: 

got it eventually - the call to put() works fine after JInternalFrame creation but I did make it before I added the component to a container. I then still had to set it's UI:

JInternalFrame iframe = new JInternalFrame("blah",true,true,true,true);
UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(248,250,175)));
UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(248,250,175)));
javax.swing.plaf.basic.BasicInternalFrameUI ui = 
    new javax.swing.plaf.basic.BasicInternalFrameUI(iframe); 
iframe.setUI(ui); 
rutherford