【发布时间】:2013-05-01 22:24:52
【问题描述】:
我在 Nimbus 中使用自定义颜色。经过数小时的搜索,我无法找到如何正确设置 JFileChooser 的背景和前景颜色。
我的(非工作)代码:
UIManager.getLookAndFeelDefaults().put("FileChooser.background", Color.DARK_GRAY);
UIManager.getLookAndFeelDefaults().put("FileChooser.textForeground", Color.white);
UIManager.getLookAndFeelDefaults().put("FileChooser.foreground", Color.white);
UIManager.getLookAndFeelDefaults().put("Label.foreground", Color.white);
根据Oracle Nimbus defaults,这应该可以,但不能。我也无法在其他任何地方找到答案。
我想改变什么
我希望标签:(查找范围:,文件夹名称:文件类型)显示为白色,浅灰色边框显示为深灰色。
提前致谢:)
更新: 我可以绕道修复一些文本颜色:
UIManager.getLookAndFeelDefaults().put("textForeground", Color.white);
UIManager.getLookAndFeelDefaults().put("Menu.textForeground", Color.white);
UIManager.getLookAndFeelDefaults().put("ToolTip.textForeground", Color.BLACK);
UIManager.getLookAndFeelDefaults().put("List.textForeground", Color.BLACK);
UIManager.getLookAndFeelDefaults().put("TextField.foreground", Color.BLACK);
UIManager.getLookAndFeelDefaults().put("TextArea.foreground", Color.BLACK);
UIManager.getLookAndFeelDefaults().put("EditorPane.foreground", Color.BLACK);
但是,JFileChooser 的框架背景仍然是浅灰色(而所有其他框架/对话框和消息对话框都遵循设置的背景颜色 DarkGray)。
我现在注意到的另一个奇怪的问题是:
弹出菜单尊重JMenuItem 的背景颜色,但忽略前景。
为了说明我的意思,我上传了一个新的IMAGE,我在其中比较了一个“正常”弹出菜单和一个出现在JFileChooser 中的弹出菜单。
【问题讨论】:
-
啊,我现在才注意到那个评论。谢谢,我去看看。
标签: java swing look-and-feel jfilechooser uimanager