JIMileChooser上的UIManager颜色 [英] UIManager color at a JFileChooser
问题描述
我正在使用Nimbus Look and Feel,其颜色只有3个变化:
I'm using Nimbus Look and Feel, with only 3 changes at its colors:
UIManager.put("nimbusSelection", new Color(164,164,164));
UIManager.put("nimbusSelectionBackground", new Color(214,217,223));
UIManager.put("nimbusSelectedText", Color.BLACK);
我的FileChooser如下所示:
My FileChooser looks like this:
因此出现所选文件的名称在白色和看起来很糟糕,它也发生在组合框中选择的文件类型。我想将它更改为黑色,但是nimbusSelectedText已经是黑色并且无法正常工作。
So selected file's name appears in white and looks bad, and it also happens for the file type selected at the combobox. I want to change it to Black, but nimbusSelectedText is already black and is not working.
我还看了一下 http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults。 html#primary 我在FileChooser或Combobox上看不到任何参数来解决这个问题。
I also had a look at the Nimbus Defaults guide at http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html#primary and i see no parameter at FileChooser or Combobox to fix this.
任何帮助确定必要的参数?谢谢
Any help identifying the necessary parameters? Thanks
推荐答案
嗯,有一种方法可以做到这一点。您可以从JFileChooser获取JList并对其进行修改:
Well, there is one way possible to do it. You can get the JList from your JFileChooser and modify it:
public boolean getJList(Container c)
{
Component[] cmps = c.getComponents();
for (Component cmp : cmps)
{
if (cmp instanceof JList)
{
modifyJList((JList)cmp);
return true;
}
if (cmp instanceof Container)
{
if(getJList((Container) cmp)) return true;
}
}
return false;
}
private void modifyJList(JList list)
{
// Here you can modify your JList
}
并使用它,只需调用 getJList()
:
JFileChooser chooser = new JFileChooser();
getJList(chooser);
这篇关于JIMileChooser上的UIManager颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!