仅更改 JComboBoxes 的 ControlShadow 颜色
我被要求将应用程序中 JComboBox 的颜色更改为非常特殊的非默认配色方案。
我发现,如果我将
System.UserInterface.Colors.SwingDefaults.ControlShadow
资源映射文件的值从:
<Color ident="ControlShadow" value="#999999"/>
更改为:
<Color ident="ControlShadow" value="#FFFFFF"/>
一切看起来都应该如此。
但是,我不想更改所有 Swing 控件的 ControlShadow Color,因此我需要找到更有针对性的修复方案。
有没有办法只为 JComboBox 更改此颜色?
请注意,我尝试更改 ComboBox.buttonShadow 的值(更改为 #FFFFFF),但这不起作用。
I've been asked to change the colors of a JComboBox in an application to a very particular, non-default color scheme.
I've found that if I change the value of the
System.UserInterface.Colors.SwingDefaults.ControlShadow
of the Resource Map file from this:
<Color ident="ControlShadow" value="#999999"/>
to this:
<Color ident="ControlShadow" value="#FFFFFF"/>
everything looks as it should.
However, I don't want to change the ControlShadow Color for all Swing controls, so I need to find a more focused fix.
Is there a way to change this color for only JComboBoxes?
Note that I tried changing the value of ComboBox.buttonShadow (to #FFFFFF) but this didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您不应该使用资源文件。
查看 UIManager 默认值,了解实现此目的的潜在方法。查看“系统颜色”以查看“controlShadow”的默认值。如果您随后查看组合框,您将看到“ComboBox.buttonShadow”具有相同的值。也许您可以更改 LAF 的此值。否则,您需要创建自定义组合框 UI。搜索源代码看看这个值用在哪里,你就会知道要更改什么。
I don't think you should be playing with the resource file.
Check out the UIManager Defaults for a potential way to do this. Look at the "System Colors" to see the default value of the "controlShadow". If you then look at the combo box you will see that the "ComboBox.buttonShadow" has the same value. Maybe you change this value for your LAF. Otherwise you need to create a custom combo box UI. Search the source code to see where this value is used and you will know what to change.