I am attempting to make the game Simon using Java Swing. However, I am unable to figure out how to change the background color of a JButton, wait for several seconds, and then change the background color back to the original color. Although several some other questions have suggested the use of Swing Timers, I am unsure of how to successfully implement these into my existing code.
I have attempted to simply using Thread.sleep() in order to pause for 2 seconds before changing the color, but the colors do not appear to be changing.
Here is my current code:
import java.util.*;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer;
import javax.swing.border.*;
public class SimonGame extends JFrame{
    private JButton begin;
    Color dullRed = new Color(255, 128, 128);
    Color dullYellow = new Color(255, 255, 128);
    Color dullBlue = new Color(128, 128, 255);
    Color dullGreen = new Color(128, 255, 128);
    Color backgroundColor = new Color(1,1,1);
    private JButton red;
    private JButton yellow;
    private JButton blue;
    private JButton green;
    // no-argument constructor
    public SimonGame()
    {      
        createUserInterface();      
    }
    // create and position GUI components; register event handlers
    private void createUserInterface()
    {
        // get content pane for attaching GUI components
        Container contentPane = getContentPane();
        // enable explicit positioning of GUI components
        contentPane.setLayout( null );
        begin = new JButton();
        begin.setBounds( 200,100,200,50 );
        begin.setText("Begin Game");
        contentPane.add( begin );
        begin.addActionListener(
                new ActionListener() // anonymous inner class
                {
                    // event handler called when submitJButton is pressed
                    public void actionPerformed( ActionEvent event )
                    {
                        try {
                            createPattern();
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                } // end anonymous inner class
                ); // end call to addActionListener
        red = new JButton();
        red.setBounds( 300,300,100,100 );
        red.setBackground(dullRed);
        red.setBorder(null);
        contentPane.add( red );
        red.addActionListener(
                new ActionListener() // anonymous inner class
                {
                    // event handler called when submitJButton is pressed
                    public void actionPerformed( ActionEvent event )
                    {
                        //submitJButtonActionPerformed( event );
                    }
                } // end anonymous inner class
                ); // end call to addActionListener
        yellow = new JButton();
        yellow.setBounds( 300,200,100,100 );
        yellow.setBackground(dullYellow);
        yellow.setBorder(null);
        contentPane.add( yellow );
        yellow.addActionListener(
                new ActionListener() // anonymous inner class
                {
                    // event handler called when submitJButton is pressed
                    public void actionPerformed( ActionEvent event )
                    {
                        //submitJButtonActionPerformed( event );
                    }
                } // end anonymous inner class
                ); // end call to addActionListener
        green = new JButton();
        green.setBounds( 200,300,100,100 );
        green.setBackground(dullGreen);
        green.setBorder(null);
        contentPane.add( green );
        green.addActionListener(
                new ActionListener() // anonymous inner class
                {
                    // event handler called when submitJButton is pressed
                    public void actionPerformed( ActionEvent event )
                    {
                        //submitJButtonActionPerformed( event );
                    }
                } // end anonymous inner class
                ); // end call to addActionListener
        blue = new JButton();
        blue.setBounds( 200,200,100,100 );
        blue.setBackground(dullBlue);
        blue.setBorder(null);
        contentPane.add( blue );
        blue.addActionListener(
                new ActionListener() // anonymous inner class
                {
                    // event handler called when submitJButton is pressed
                    public void actionPerformed( ActionEvent event )
                    {
                        //submitJButtonActionPerformed( event );
                    }
                } // end anonymous inner class
                ); // end call to addActionListener
        setTitle( "Simon Game" ); // set title bar string
        setSize( 600, 600 );     // set window size
        setVisible( true );
    }
    private void setDefaultColors(){
        red.setBackground(dullRed);
        yellow.setBackground(dullYellow);
        blue.setBackground(dullBlue);
        green.setBackground(dullGreen);
    }
    private void createPattern() throws InterruptedException
    {
        Random rand = new Random();
        int iter = 4;
        int generatedPattern[] = new int[iter];
        for(int i = 0; i<iter; i++)
        {
            int randomColor = rand.nextInt(4) +1;
            generatedPattern[i] = randomColor;
            switch(randomColor)
            {
                case 1:
                    red.setBackground(Color.RED);
                    Thread.sleep(2000);
                    red.setBackground(dullRed);
                    break;
                case 2:
                    yellow.setBackground(Color.YELLOW);
                    Thread.sleep(2000);
                    yellow.setBackground(dullYellow);
                    break;
                case 3:
                    blue.setBackground(Color.BLUE);
                    Thread.sleep(2000);
                    blue.setBackground(dullBlue);
                    break;
                case 4:
                    green.setBackground(Color.GREEN);
                    Thread.sleep(2000);
                    green.setBackground(dullGreen);
                    break;
                default:
                    System.out.print("The program is super broken");
                    break;
            }
        }
    }
    public static void main( String[] args )
    {
        SimonGame application = new SimonGame();
        application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    } // end method main
}
I would greatly appreciate any assistance.
Thank you.