Hello,
I'm currently working on a small Mastermind game where the user has to guess the colors which the computer is thinking of. To do this they will have to press a number of buttons which then change colors until they are satisfied.
Here's my problem: I want to use JButtons with the setBackground() method but it doesn't work. After some searching I found the setOpaque method but it didn't help me at all (no effect). I even tried setOpaque on the JPanel which the button is placed on.
Here's my current code:
for (int i = 0; i<numberOfPegs; i++) {
buttons[i] = new JButton();
buttons.setOpaque(true);
buttons[i].setBackground(Color.GREEN);
buttons[i].setBounds(new Rectangle(12+(pegSize+5)*i+10, (pegSize+6)*(numberOfTries+1), pegSize, pegSize));
gamePanel.add(buttons[i]);
}
I use 1.6 with Eclipse on Mac OS X 10.5.6. Any help would be greatly appreciated.
Edited by: pg-robban on Feb 5, 2009 3:40 AM