Skip to content
Advertisement

Background color of the selected item in an uneditable JComboBox

The background color of the selected item in an uneditable JComboBox is a sort of blue:

alt text

Is there any way to make this a different color, such as white, for example?

Advertisement

Answer

This should work

jComboBox1.setRenderer(new DefaultListCellRenderer() {
    @Override
    public void paint(Graphics g) {
        setBackground(Color.WHITE);
        setForeground(Color.BLACK);
        super.paint(g);
    }
});
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement