0

嗨,我想在我的应用程序中更改所有 ComboBoxes 的外观。

MyComboBox 类:

class MyComboBoxUI extends BasicComboBoxUI {


    public static ComponentUI createUI(JComponent c) {
        return new MyComboBoxUI();
    }

    protected JButton createArrowButton() {
        JButton button = new BasicArrowButton(BasicArrowButton.EAST);
        return button;
    }
}

我这样称呼它:

UIManager.put("ComboBoxUI", "MyComboBoxUI");

它会产生此错误:

UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JComboBox

当我使用:

someComboBox.setUI((ComboBoxUI) MyComboBoxUI.createUI(someComboBox));

它就像一个魅力

4

0 回答 0