Exceen
Exceen

Reputation: 765

Setting the background of a JComboBox?

I want to set the background of a JComboBox. I have a form in a JPanel with several JTextFields, JTextAreas and JComboBoxes. For every component I use in my program, the .setBackground is usually fine, except for the JComboBoxes.

Even when I say comboBox.setBackground(new Color(210, 210, 210)), the background stays the same as you can see here:

enter image description here

It's basically just a little detail, but the color of the corners simply doesn't change. I want to change the color of this corners. When using JButtons, the .setBackground()-method is fine as well. Why is it only for JComboBoxes different and what is the right method?

Solution

I finally figured out how to change this 'background'. It's actually part of the border. Thus, changing the border(color) fixed that for me.

Upvotes: 1

Views: 1383

Answers (1)

user1134181
user1134181

Reputation:

See here how to do it - UIManager

UIManager.put("ComboBox.background", new ColorUIResource(Color.magenta));

Upvotes: 3

Related Questions