是否可以更改JFrame或JInternalFrame的标题栏颜色 [英] is it possible to change titlebar color of JFrame or JInternalFrame

查看:693
本文介绍了是否可以更改JFrame或JInternalFrame的标题栏颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改标题栏颜色。但它不起作用

UIManager.put(JFrame.activeCaption,new javax.swing.plaf.ColorUIResource(Color.GREEN));
JFrame.setDefaultLookAndFeelDecorated(true);

I am trying to change title bar color.but it dosen't work
UIManager.put("JFrame.activeCaption", new javax.swing.plaf.ColorUIResource( Color.GREEN)); JFrame.setDefaultLookAndFeelDecorated(true);

推荐答案

我认为你不能对颜色做任何事情。 JFrame 的标题栏,至少没有使用本机代码来实现特定于平台的解决方案。那是因为 JFrame 实际上使用你的原生窗口系统来创建窗口。

I do not think that you can do anything about the colors in the title bar of a JFrame, at least not without using native code to implement a platform-specific solution. That is because JFrame actually uses your native windowing system to create the window.

至于内部框架,它会因为它是一个由Java控制的窗口内部呈现的组件,所以能够自定义它。确实,有很多 JInternalFrame 您可以在UI管理器中设置的属性。但是,我无法让这些工作在我的系统上。

As for internal frames, it would make sense for you to be able to customize it, since it is a component rendered inside of a window that is controlled by Java. Indeed, there are plenty of JInternalFrame properties that you can set in your UI manager. However, I wasn't able to get those to work on my system.

做一些谷歌搜索,似乎其他人发现你无法改变 JInternalFrame 的外观更改整个系统的外观设置。因此,即使使用内部框架,我担心您可能不得不依赖操作系统来控制标题栏的颜色。

Doing a little googling, it appears that others have found that you cannot change the appearance of JInternalFrame without changing your whole system's look and feel settings. So, I'm afraid that you might have to depend on the operating system to control the colors of your title bars even when using internal frames.

这篇关于是否可以更改JFrame或JInternalFrame的标题栏颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆