Hi,
I have to program the Mastermind game( dont' know if anyone knows it). Anyway I've got my GUI looking quite pretty :), but I want to know something on working with Colors. I' ve got 6 colors to choose from and I have given differernt rgb values for these colors. I want to know how, when I click on one color eg red, the first button( I used buttons) , turns to red- I ve tried with setBackground but I don't think its right . I've thought about using a getColor Method that would return red for example. I need some guidance . Thanks
I havent posted my entire code- it's long
I have to program the Mastermind game( dont' know if anyone knows it). Anyway I've got my GUI looking quite pretty :), but I want to know something on working with Colors. I' ve got 6 colors to choose from and I have given differernt rgb values for these colors. I want to know how, when I click on one color eg red, the first button( I used buttons) , turns to red- I ve tried with setBackground but I don't think its right . I've thought about using a getColor Method that would return red for example. I need some guidance . Thanks
Code:
//part of the code where I add an action listener for one color // should be possible to do for all colors color_one.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent event) { if (event.getSource() == color_one) { //guess_buttons[0][0].setBackground(red); // } } });
Comment