title: JFrame - Output method results into a JLabel
body: <p>I've made a silly random sentence generator for practice, and I'm now trying to get the results to display in a JLabel. I am rather stuck, and after trying to follow some tutorials at getting console output into a JTextArea or JLabel, I've decided that's not what I'm trying to achieve. I just want so when I've clicked my button, it runs the wordGen class and outputs its results into my JLabel.</p>
  
  <p>Here is my code snippet:</p>
  
  <pre><code>package proGui;
  import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  
  public class HelloWorldGUI2 {
  
  private static class HelloWorldDisplay extends JPanel {
      public void paintComponent(Graphics g) {
          super.paintComponent(g);
  //          g.draw3DRect(20, 30, 100, 100, true);
      }
  
  }
  
  private static class ButtonHandler implements ActionListener {
      public void actionPerformed(ActionEvent e) {
          return wordGen(); // This is me trying to get the button when clicked to run the wordGen class. Obviously completely wrong.
      }
  }
  
  public static class wordGen  {
      // Make three sets of words to choose from
      String[] wordListOne = {"24/7","Terrific","Time-tested","Returned","Tried","Intepreted","Ebay","Large","Small","Medium"};
      String[] wordListTwo = {"Oriented","Shared","Aligned","Targeted","Leveraged","Charged","Networked","Centric","Distributed","Postioned"};
      String[] wordListThree = {"Bush-beater","Pikestaff","Placket-racket","Hammer-handle","Quim-wedge","Creamstick","Tug-mutton","Kennel-raker","Testicles","Penis","Vagina","Breasts","TallyWhacker","Johnson","Meat","ClamFist","Binlid"};
  
      //find out how many words are in each list
      int oneLength = wordListOne.length;
      int twoLength = wordListTwo.length;
      int threeLength = wordListThree.length;
  
      //generate three random numbers
      int rand1 = (int) (Math.random() * oneLength);
      int rand2 = (int) (Math.random() * twoLength);
      int rand3 = (int) (Math.random() * threeLength);
  
      //now build a phrase
      String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
  }
  
  public static void main(String[] args) {
      HelloWorldDisplay displayPanel = new HelloWorldDisplay();
      JButton okButton = new JButton("New Word Combo"); // Create new button
      okButton.setFont(new Font("Malina Light",Font.TRUETYPE_FONT,14)); // Assign     custom font to new button
      ButtonHandler listener = new ButtonHandler();
      okButton.addActionListener(listener);
  
      //Text Label - For the eventual output of the random sentence generator
      JLabel jLab = new JLabel(wordGen);
  
      JPanel content = new JPanel();
      content.setLayout(new BorderLayout());
      content.add(displayPanel, BorderLayout.CENTER);
      content.add(okButton, BorderLayout.SOUTH);
      content.add( jLab, BorderLayout.NORTH );
  
      JFrame window = new JFrame("GUI Test"); // Declaring the variable 'window'     to type JFrame and sets it to refer to a new window object within the statement
      window.setContentPane(content);
      window.setSize(250,150);
      window.setLocation(100,100);
      window.setVisible(true);
  
      }
  }
  </code></pre>
  
  <p>Anyway, I apologise for being n00bish, but this is last piece of my mini programming puzzle!</p>