手动设置 Swing JInternalFrame lnf

发布于 2024-08-20 03:37:23 字数 750 浏览 8 评论 0原文

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);

为什么我的内部框架的标题背景在启动时没有设置?

我尝试在整体 JFrame init 上设置它,但没有什么区别(相比之下,我可以更改其他 JFrame ui 组件的外观和感觉,例如 MenuItem.background 在这个位置,所以我认为这可能是因为 JInternalFrame 不是顶级组件,即选项卡式窗格下的组件,也许它需要在其他点进行更改,但是在哪里? )

关于为 JInternalFrame 调用 UIManager.put() 的正确位置有什么提示吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦情居士 2024-08-27 03:37:23

最终得到它 - 在 JInternalFrame 创建之后对 put() 的调用工作正常,但我在将组件添加到容器之前确实做到了。然后我仍然需要设置它的用户界面:

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); 

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); 
晨光如昨 2024-08-27 03:37:23

我认为您需要在创建任何 Swing 组件之前对 UIManager.put 进行所有调用。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文