JRE Version 1.7 Update 3
EXPECTED BEHAVIOUR
As I run the program, it works as expected, everything works smoothly. As when
I am unsure whether I found a solution for your system, but adjusting the code to
colourButton = new JButton( "BALL COLOUR" );
colourButton.setOpaque( true );
colourButton.setBackground( colours[ colourCounter ] );
colourButton.setForeground( Color.WHITE );
works on my system (OS X with Java 1.7). Note the setOpaque
call, which is needed so that the setBackground
call has any effect as stated in the javadoc of that method:
Sets the background color of this component. The background color is used only if the component is opaque
On OS X, without that setOpaque
call your code does not even work before a resize