title: Java Swing, On button click, output to JTextArea
body: <p>I have 2 classes one of which is a GUI.</p>
  
  <p>My first class is called MusicSearch.java and it has this:</p>
  
  <pre><code>public static void directoryMusicLocator(File dir) {
      try 
      {
          String[] filetype = new String[] { "mp3" }; // only search mp3 files
          System.out.println("Getting all .mp3 files in " + dir.getCanonicalPath() + " including those in subdirectories");
          List&lt;File&gt; files = (List&lt;File&gt;) FileUtils.listFiles(dir, filetype, true);
          for (File file : files) 
          {
              System.out.println(file.getAbsolutePath()); // get the file's absolute path
          }
          System.out.println("\nFinished Searching.");
      }
      catch (IOException e) 
      {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>What this does is that it searches for Mp3 files on a directory for example C:\Music</p>
  
  <p>For the GUI, well I created it using netbeans' JFrame Designer and a screenshot of this can be seen on the image below. (I can't embed images at the moment so I can only provide a link to the image.)</p>
  
  <p><a href="http://i.stack.imgur.com/7pLPL.jpg" rel="nofollow">http://i.stack.imgur.com/7pLPL.jpg</a></p>
  
  <p>On the JTextField next to the "Enter Location", the user enters a location for example C:\Music. When the user clicks the button "Find MP3's" the method directoryMusicLocator is called. Below is the Action Listener for the Find MP3's button:</p>
  
  <pre><code>private void findMP3ButtonActionPerformed(java.awt.event.ActionEvent evt) {                                              
      // TODO add your handling code here:
      String fLocation = dirToSearch.getText(); // this gets the input from the textfield
      File dir = new File(fLocation); // converts the location to path
      MusicSearch.directoryMusicLocator(dir); 
  }
  </code></pre>
  
  <p>An example of the output can be seen below when it is ran and user entered C:\Music on the textfield:    </p>
  
  <pre><code>C:\Music\Feint - Times Like These (Fracture Design Remix).mp3
  C:\Music\Ficci - Climax (FREE).mp3
  C:\Music\Ficci - Making Me Blue (FREE).mp3
  </code></pre>
  
  <p>Now what I want is the output to display on the JTextArea but I don't know how. Can someone tell me how.</p>
  
  <p>Thanks</p>