title: How to make an audio file player that plays a random file each time
body: <p>I am trying to make a program that plays a random WAV file each time the button is pressed. I have everything set up except for how to make it play a random file. How would I make it play a random file from the selection of the two files I have? </p>
  
  <pre><code>public class joeyMain {
  
  public static void main(String[] args) {
      GUI g = new GUI();
      g.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      g.setSize(300,200);
      g.setVisible(true);
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public class GUI extends JFrame{
  
  static void PlaySound(File Sound){
      try{
          Clip clip = AudioSystem.getClip();
          clip.open(AudioSystem.getAudioInputStream(Sound));
          clip.start();
  
          Thread.sleep(clip.getMicrosecondLength()/1000);
      }catch(Exception e){
  
      }
  }
  
  private JButton r;
  
  public GUI(){
      super("AreaFinder");
      setLayout(new FlowLayout());
      setSize(800, 800);
  
      r = new JButton("Random Joey Quote");
      r.addMouseListener(new MouseListener() {
          public void mouseClicked(MouseEvent arg0) {
              File Joey1 = new File("video1.WAV");
              File Joey2 = new File("video2.WAV"); 
              PlaySound(Joey1);
          }
          public void mouseEntered(MouseEvent arg0) {}
          public void mouseExited(MouseEvent arg0) {}
          public void mousePressed(MouseEvent arg0) {}
          public void mouseReleased(MouseEvent arg0) {}
      });
      add(r);
  }
  </code></pre>
  
  <p>}</p>