在特定的LookAndFell中设置不可编辑的JComboBox的背景

时间:2014-04-28 16:01:40

标签: java swing combobox jcombobox look-and-feel

我正在使用这个特定的LookAndFeel:

    PlasticLookAndFeel.setPlasticTheme(new com.jgoodies.looks.plastic.theme.SkyBluer());
    UIManager.setLookAndFeel(new com.jgoodies.looks.plastic.PlasticLookAndFeel());

我使用此代码设置可编辑的JComboBox命名组件的背景:

    ComboBoxEditor editor = component.getEditor();
    JTextField textField = (JTextField) editor.getEditorComponent();
    textField.setBackground(color);

结果是:

enter image description here

如果我对不可编辑的组合框使用相同的代码,则不会发生任何事情:

enter image description here

如果我将此代码用于不可编辑的组合框:

    ((JComboBox)component).setBackground(color);

结果是颜色外推了组件大小。像这个图:

enter image description here

1)有没有人知道如何设置不可编辑组合框的背景而不推断这个特定LookAndFell的大小?

0 个答案:

没有答案