更改 JFileChooser 的颜色
我试图按照这篇文章中的一些想法更改 JFileChooser 的颜色:
更改 JFileChooser 中 WindowsPlacesBar 的颜色
但是我无法这样做,我找不到缺少哪些代码。到目前为止我只得到这个:
UIManager.put("Panel.background", Color.BLACK);
UIManager.put("Button.background", Color.BLACK);
UIManager.put("ComboBox.background", Color.BLACK);
UIManager.put("ComboBox.foreground", Color.WHITE);
UIManager.put("TextField.background", Color.BLACK);
UIManager.put("TextField.foreground", Color.WHITE);
UIManager.put("ToolBar.background", Color.BLACK);
UIManager.put("Viewport.background", Color.BLACK);
UIManager.put("Viewport.foreground", Color.WHITE);
SwingUtilities.updateComponentTreeUI(this);
I was trying to change the color of my JFileChooser following some ideas from this post:
Change color of WindowsPlacesBar in JFileChooser
However I was not able to do so, I could not found which code is missing. Until now I got only this:
UIManager.put("Panel.background", Color.BLACK);
UIManager.put("Button.background", Color.BLACK);
UIManager.put("ComboBox.background", Color.BLACK);
UIManager.put("ComboBox.foreground", Color.WHITE);
UIManager.put("TextField.background", Color.BLACK);
UIManager.put("TextField.foreground", Color.WHITE);
UIManager.put("ToolBar.background", Color.BLACK);
UIManager.put("Viewport.background", Color.BLACK);
UIManager.put("Viewport.foreground", Color.WHITE);
SwingUtilities.updateComponentTreeUI(this);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
或者,如果您愿意:
or, if you prefer:
您需要创建一个 CustomFileChooser 类并重写 createDialog(Componentparent) 方法并设置对话框的 contentPane 背景颜色并设置对话框中每个组件的背景,
You need to create a CustomFileChooser class and override createDialog(Component parent) method and set the dialog's contentPane background color and set background of each component in the dialog,
我搞乱了一点想出了这个:
I messed around a little a came up with this: