手动设置Swing JInternalFrame lnf [英] setting Swing JInternalFrame lnf manually
问题描述
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?
我尝试将其设置在整个JFrame
init上,但没有区别(通过对比,我可以在此位置更改其他JFrame
ui组件的外观,例如MenuItem.background
,所以我认为可能是因为JInternalFrame
并不是顶级组件,即在选项卡式窗格下,所以可能需要在其他位置进行更改,但是在哪里?)
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?)
在正确的地方打电话给JInternalFrame
的任何提示吗?
Any tips on the correct place to call UIManager.put()
for JInternalFrame
?
推荐答案
最终得到了它-在JInternalFrame创建之后,对put()的调用工作正常,但是在将组件添加到容器中之前我做到了.然后,我仍然必须设置它的UI:
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);
这篇关于手动设置Swing JInternalFrame lnf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!