Set ComboBoxUI for all JComboBoxes

447 views Asked by At

Hi I want to change look for all ComboBoxes in my app.

MyComboBox class:

class MyComboBoxUI extends BasicComboBoxUI {


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

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

And i call it like this:

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

It produces this error:

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

When i use:

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

It works like a charm

0

There are 0 answers