您好我想在我的应用中更改所有ComboBox的外观。
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));
它就像一个魅力