我应该设置什么外观组件来更改 TitledBorder 的文本颜色?
我的 Swing 应用程序中有一组单选按钮,它们周围有一个边框,如下所示:
radioButtonPanel.setBorder( new CompoundBorder (
BorderFactory.createTitledBorder( " Input Data " ), padBorder ) );
我们的应用程序支持两种外观和感觉:浅色和深色。在两者之间切换时,边框颜色本身似乎会正确更改颜色,但文本不会。对于我的一生,我无法弄清楚我应该设置颜色的组件的名称是什么。 createTitledBorder() 的文档说它使用默认的外观和感觉,但我不确定它在哪里提取默认值。我以为是 Panel.foreground
,但事实并非如此,而且其他看起来都不太正确。
有人知道我需要在这里设置哪个外观和感觉组件吗?
I have a group of radio buttons in my Swing application that have a border built around them as follows:
radioButtonPanel.setBorder( new CompoundBorder (
BorderFactory.createTitledBorder( " Input Data " ), padBorder ) );
Our application supports two look and feels, a light and a dark one. When switching between the two, the border color itself appears to change colors correctly, but the text does not. For the life of me, I can't figure out what the name of the component is I should be setting the color of. The documentation for createTitledBorder()
says it uses the default look and feel, but I'm unsure where it's pulling its default. I thought it was the Panel.foreground
, but that's not it and nothing else seems to look quite right.
Does anybody know which look and feel component I need to be setting here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 TitledBorder 实例上设置标题颜色,或使用将标题颜色作为参数的构造函数创建一个实例。
TitledBorder javadoc 还指出“外观中的“TitledBorder.titleColor”属性用作默认值。您可以按如下方式覆盖它:
You can set the title colour on a TitledBorder instance or create one using a constructor that takes the title colour as an argument.
The TitledBorder javadoc also states that "TitledBorder.titleColor" property from the look and feel is used as the default. You can override this as follows:
您无需致电,而是
需要致电
Instead of calling
you will need to call