0
我在JList上使用這種方法在JFileChooser上定義了一個JComboBoxes。福阿德建議here自定義JFileChooser:FileFilters丟失
public void customizeJFileChooser(Container c)
{
Component[] cmps = c.getComponents();
for (Component cmp : cmps)
{
if (cmp instanceof JList)
{
((JList)cmp).setSelectionBackground(new Color(164,164,164));
}
if (cmp instanceof JComboBox)
{
((JComboBox)cmp).setRenderer(new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (isSelected)
comp.setBackground(new Color(164,164,164));
return comp;
}
});
}
if (cmp instanceof Container)
{
customizeJFileChooser((Container) cmp);
}
}
}
的偉大工程的顏色,但......現在我已經用的FileFilter名稱的問題,因爲你可以在上面看到:
如果我不叫customizeJFileChooser它的名稱是正確的,所以它必須是該方法的問題。任何幫助?
'Object.toString()' – mKorbel