title: JButton stays pressed and I can't click and anything when I play a song on my GUI
body: <p>I wrote a program the is basically a picture slide show that also displays text and plays music. Everything works well except when I press my JButton titled "Play Song". When I press this button the songs play but the button remains pressed and I can't click and anything in GUI. The way I load in the songs in I have an array that contains all the pathnames of the fils in a selected folder, then I use FileInputStream to load in the file using a pathname from the array. Once the file is loaded in it is then played. I thought this was the best way to read in .mp3 files and play them because I take a similar approach in the way I read in all the images from a selected folder and that works well. Any help would be greatly appreciated!
  This is the file that contains my main method and it contains the class the creates the GUI and holds all the method except the one to play music:</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import java.awt.image.*;
  import java.io.*;
  import java.net.URL;
  import java.util.*;
  import javax.imageio.*;
  import javax.swing.*;
  @SuppressWarnings("serial")
  public class Aubs extends JFrame
  {
    static File pics[] = null;
    JLabel label;
    JPanel panel;
    JTextArea quoteDisplay, imageDisplay;
    JButton newQuote, newBC, newText, song;
    ArrayList&lt;String&gt; quotes = new ArrayList&lt;String&gt;();
    public Aubs()
    {
       loadPics(); 
       panel = new JPanel();
       panel.setLayout(null);
       panel.setBackground(Background()); 
       add(panel);
  
       label = new JLabel(); 
       setPics();
       changePic e = new changePic();
       label.addMouseListener(e);
       panel.addMouseListener(e);
  
       song = new JButton("Play Song"); // The button to change song
       song.setBounds(1000,115,185,30);
       song.addActionListener(new Song()); // Add ActionListener 
       panel.add(song); // Adds the button to the screen
  
       imageDisplay = new JTextArea("Click the image for a new one");
       imageDisplay.setBounds(630,30,300,300);
       imageDisplay.setFont(new Font("FatFrank",Font.BOLD,16));
       imageDisplay.setForeground(Font()); // Sets the font color
       imageDisplay.setOpaque(false);
       imageDisplay.setEditable(false);
       panel.add(imageDisplay);
       panel.setBackground(Background()); 
  
       quoteDisplay = new JTextArea();
       setQuotes();
  
       newQuote = new JButton("Quote");
       newQuote.setBounds(1000,0,185,40);
       newQuote.addActionListener(new changeQuote()); 
       newQuote.setForeground(Color.BLACK); 
       panel.add(newQuote);
  
       newBC = new JButton("New Background Color");
       newBC.setBounds(1000,90,185,30);
       newBC.addActionListener(new newBack());
       newBC.setForeground(Color.BLACK);
       panel.add(newBC);
  
       newText = new JButton("New Font color");
       newText.setBounds(1000,65,185,30);
       newText.addActionListener(new newFont());
       newText.setForeground(Color.BLACK);
       panel.add(newText);    
  
  
   }
   private void loadPics()
   {
      JFileChooser choose = new JFileChooser();
      choose.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      int status = choose.showOpenDialog(null);
      if (status == JFileChooser.APPROVE_OPTION) 
      {
           File dir = choose.getSelectedFile(); 
              if (dir.exists()) 
              {
                  pics = dir.listFiles(new FileFilter()
                  {
                       @Override
                          public boolean accept(File pathname) 
                          {
                              String name = pathname.getName().toLowerCase();
                              return name.endsWith(".png")
                                      || name.endsWith(".jpg")
                                      || name.endsWith(".jpeg")
                                      || name.endsWith(".bmp")
                                      || name.endsWith(".gif");
                          }
                  });
              }
      }
  }
  private void setPics()
  {
      int i = (int)(Math.random()*pics.length); // Chooses a number for index
      try 
      {
          BufferedImage buff = ImageIO.read(pics[i]); // Reads in the image
          ImageIcon icon = new ImageIcon(buff); // Converts it to an ImageIcon
          icon = transform(icon); // Resizes
          label.setIcon(icon);
          label.setBounds(10,10,600,700); 
          panel.add(label);
          panel.setBackground(Background());
      } 
      catch (IOException e) 
      {
          e.printStackTrace();
      }
  }
  
  private ImageIcon transform(ImageIcon x) // Resizes the Image
  {
      ImageIcon temp = x;
      Image image = temp.getImage();
      Image tempImg = image.getScaledInstance(600,700,java.awt.Image.SCALE_SMOOTH );
      temp = new ImageIcon(tempImg);
      return temp;
  }
  private void loadQuotes()
  {
      URL url = getClass().getResource("Quotes/Quotes.txt");
      try{    
          Scanner scan = new Scanner(new FileInputStream(url.getPath()));
  
          while(scan.hasNextLine())
          {   
              quotes.add(scan.nextLine());
          }
          scan.close();
      }
      catch(Exception ex)
      {
          System.out.println("File not found");
      }
  }
  private void setQuotes()
  {
      loadQuotes();
      int q = (int)(Math.random()*quotes.size());
      quoteDisplay.setText(quotes.get(q));
      quoteDisplay.setBounds(650,100,200,400);
      quoteDisplay.setFont(new Font("FatFrank",Font.BOLD,16));
      quoteDisplay.setForeground(Font());
      quoteDisplay.setLineWrap(true);
      quoteDisplay.setWrapStyleWord(true);
      quoteDisplay.setOpaque(false);
      quoteDisplay.setEditable(false);
      panel.setBackground(Background());
      panel.add(quoteDisplay);
      imageDisplay.setBackground(Background());
  }
  private Color Font()
  {
      int r = (int)(Math.random() *256);
      int g = (int)(Math.random() *256);
      int b = (int)(Math.random() *256);
      return (new Color(r, g, b).brighter());
  }
  private Color Background()
  {
      int r = (int)(Math.random() *256);
      int g = (int)(Math.random() *256);
      int b = (int)(Math.random() *256);
      return (new Color(r, g, b).darker());
  }
  public void playSong()
  {
      MP3 play = new MP3(); // Creates and object of MP3
      play.play(); // Calles the play method in MP3
  }
  private class changePic implements MouseListener
  {
      public void mouseClicked(MouseEvent e) 
      {
          setPics();
          quoteDisplay.setForeground(Font());
          imageDisplay.setForeground(Background());
      }
      public void mousePressed(MouseEvent e) {}
      public void mouseReleased(MouseEvent e) {}
      public void mouseEntered(MouseEvent e) {}
      public void mouseExited(MouseEvent e){}
  }
  private class changeQuote implements ActionListener
  {
      public void actionPerformed(ActionEvent q) 
      {
          setQuotes();
      }
  }
  private class newBack implements ActionListener
  {
      public void actionPerformed(ActionEvent bc) 
      {
          panel.setBackground(Background());
      }       
  }
  private class newFont implements ActionListener
  {
      public void actionPerformed(ActionEvent fc) 
      {
          quoteDisplay.setForeground(Font());
          imageDisplay.setForeground(Font());
      }
  }
  public class Song implements ActionListener // Supposes to change the song when a button is pressed
  {
      public void actionPerformed(ActionEvent s) 
      {
          playSong();
      }   
  }
  public static void main(String[] args)
  {
      Aubs aubs = new Aubs();
      aubs.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      aubs.setSize(new Dimension(1200, 1000));
      aubs.setVisible(true);
  }
  </code></pre>
  
  <p>}
  Here is the class that plays the music:</p>
  
  <pre><code>import javazoom.jl.player.*;
  import java.io.*;
  import java.util.ArrayList;
  public class MP3 
  {   
    static File list[] = null;
    ArrayList&lt;Player&gt; songs = new ArrayList&lt;Player&gt;();
    public void play()
    { 
       MP3Files(); // Loads the pathnames to the array list[].
       int i = 0; // Will be the count of the files loaded in
       int x = (int)(Math.random()*i); 
       try
      { 
          Player cur;
          if(i &gt;= list.length-1) // True when all files are loaded,
          {
              cur = songs.get(x); // Then it chooses a random song 
              cur.play(); // Play that song
          }
          else // True when not all files from list[] are loaded,
          {
              FileInputStream in = new FileInputStream(list[i]); 
              songs.add(new Player(in)); //add the song to theArrayList. 
              cur = songs.get(x); // Get random song
              cur.play(); // Play random song
              i++;
          }
      }
      catch(Exception e)
      {
          System.out.println("Error");
      }
  }       
  public static void MP3Files() // Loads all the pathnames 
  {
      File dir = new File("/Users/mine/Desktop/Music"); 
      if(dir.isDirectory())
      {
          list = dir.listFiles(new FileFilter() // the pathnames.
          {
              @Override
               public boolean accept(File pathname) 
               {
                  String name = pathname.getName().toLowerCase();
                  return name.endsWith(".mp3");
  
               }
           });
      }
  }
  </code></pre>
  
  <p>}</p>