I have the following problem :
I need to set a custom UI for a JComboBoxComponent
(to modify colors, arrow button etc.) Currently, I'm doing it in a constructor, like this :
public MyComboBox() {
setUI(new MyComboBoxUI);
}
Problem is, after setting UI in such way, I somehow loose all InputMap
and ActionMap
contents for list in combo box popup, i.e. it doesn't scroll list up or down with arrow keys.
What am I doing wrong here?
Here's the code :
public class CurrencyPairComboBox extends JComboBox {
public CurrencyPairComboBox() {
setUI(new CurrencyPairComboBoxUI());
}
}
class CurrencyPairComboBoxUI extends BasicComboBoxUI {
@Override
public void installUI(JComponent c) {
super.installUI(c);
listBox.setSelectionBackground(Color.BLACK);
listBox.setSelectionForeground(Color.WHITE);
}
@Override
protected JButton createArrowButton() {
arrowButton = new JButton();
arrowButton.setIcon(OrderWidgetUIConstants.DROPDOWN_ARROW_ICON);
arrowButton.setRolloverIcon(OrderWidgetUIConstants.DROPDOWN_ARROW_HOVER_ICON);
return arrowButton;
}
}