I'm trying to make a Java program that displays a red-green-blue background, with a 1-second pause after updating. I tried this:
Container content = frame.getContentPane();
content.setBackground(Color.RED);
Thread.sleep(1000);
content.setBackground(Color.GREEN);
Thread.sleep(1000);
content.setBackground(Color.BLUE);
However, this just waits 2 seconds then displays a blue background. Can anyone give me a fix?
I'm a total noob at Swing so a little explanation would be greatly appreciated. Also, is there any way to loop the colour change? Thanks!