I am creating a small java game for a school project. I am using some components of JFrame; JPanels, JLabels, JComboBoxs.
Image of my JComboBox:
I want to change the blue-ish colour of the JComboBox to another colour (Brown). How can I go about doing this?
I have tried changing the background and the foreground of the JComboBox itself but I cannot seem to get it to work. The foreground makes the text change and the background changes the already brown colour. Here is my entire JComboBox code:
raceStatsComboBox = new javax.swing.JComboBox<>();
raceStatsComboBox.setModel(new DefaultComboBoxModel<>(new String[] { "GOBLIN", "OGRE", "ORC" }));
raceStatsComboBox.setBounds(75, 120, 300, 80);
raceStatsComboBox.setFont(new Font(bodyFont, Font.BOLD, 25));
//HERE IS WHERE I DEAL WITH THE FOREGROUND AND BACKGROUND
raceStatsComboBox.setBackground(new Color(121, 92, 50));
raceStatsComboBox.setForeground(Color.WHITE);
raceStatsComboBox.setBorder(new MatteBorder(10, 10, 10, 10, new Color(58, 31, 4)));
raceStatsComboBox.setOpaque(true);
((JLabel)raceStatsComboBox.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
raceStatsComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
raceSelector(evt);
}
});
mainPanel.add(raceStatsComboBox);
