I have around 50 buttons .some are green(selected),some are grey(deselected). If i press the green buttons ,they should change their colour to red and back to green on pressing again. If i press the grey buttons ,they should change their colour to green and back to grey on pressing again. All buttons have some text in black.On pressing the buttons,the colour of the text remains unchanged. Suggest a solution or tutorial for same...
Asked
Active
Viewed 230 times
1 Answers
5
Don't use a JButton for this but instead use a JToggleButton. Consider giving them ImageIcons for their state.

Hovercraft Full Of Eels
- 283,665
- 25
- 256
- 373
-
2@Mandeep Singh `On pressing the buttons,the colour of the text remains unchanged` use [JButton(JToggleButton).setForeground](http://docs.oracle.com/javase/tutorial/uiswing/components/button.html) – mKorbel Jul 04 '12 at 21:08