Auto-close a JOptionPane in a for loop
<p>I am a bit lost, I have asked my professor the same question and I don't really understand how to implement the answer.  My code (below) basically creates 7 ImageIcon's, then I implement a for loop where it randomly calls the pictures.  This works fine, my question is how do I leave each ImageIcon up for 250ms, then have it close without input from the user and then move on to the next image until the for loop is completed? </p>

<pre><code>package test;
import javax.swing.*;




public class TEST {


public static void main(String[] args) {
    //create a timer


    //try to assign variables to pictures in an array
    ImageIcon icon = new ImageIcon("/home/james/programmingpics/A_Guitar");
    JOptionPane.showMessageDialog(null, "A Note", "A Note with Guitar", 
    JOptionPane.OK_OPTION, icon);        

    ImageIcon icon1 = new ImageIcon("/home/james/programmingpics/B_Guitar");
    JOptionPane.showMessageDialog(null, "B Note", "B Note with Guitar", 
    JOptionPane.OK_OPTION, icon1);


    ImageIcon icon2 = new ImageIcon("/home/james/programmingpics/C_Guitar");
    JOptionPane.showMessageDialog(null, "C Note", "C  Note with Guitar", 
    JOptionPane.OK_OPTION, icon2);

    ImageIcon icon3 = new ImageIcon("/home/james/programmingpics/D_Guitar");
    JOptionPane.showMessageDialog(null, "D Note", "D Note with Guitar", 
    JOptionPane.OK_OPTION, icon3);

    ImageIcon icon4 = new ImageIcon("/home/james/programmingpics/E_Guitar");
    JOptionPane.showMessageDialog(null, "E Note", "E Note with Guitar", 
    JOptionPane.OK_OPTION, icon4);

    ImageIcon icon5 = new ImageIcon("/home/james/programmingpics/F_Guitar");
    JOptionPane.showMessageDialog(null, "F Note", "F Note with Guitar", 
    JOptionPane.OK_OPTION, icon5);        

    ImageIcon icon6 = new ImageIcon("/home/james/programmingpics/G_Guitar");
    JOptionPane.showMessageDialog(null, "F Note", "F Note with Guitar", 
    JOptionPane.OK_OPTION, icon6);

    ImageIcon[] iconarray = {icon, icon1, icon2, icon3, icon4, icon5,
        icon6};


    for (int i = 0; i &lt; 1000; i++) {
   int random = 1 * (int) ((Math.random() * 100) % 7);
   System.out.println(iconarray[random]);
    }
}
}
</code></pre>
