title: Print to GUI text fields?
body: <p>I'm trying to create a GUI Lottery program in Java. The actual code for the Lottery program works pretty well and I have created the GUI as well. The problem is that I can not get the program to run when the "Go" button is pressed and the information is not displayed in the corresponding GUI text fields.</p>
  
  <p>Here is the basic Lotto code with out the GUI involved at all:</p>
  
  <pre><code>    package slots;
  
      import java.util.*;
  
  public class Slots {
  static int displaynum[] = new int[5];
  static int compnum[] = new int[5];
  static int counter=0;
  static int matchFound=0;
  static int nummatch[] = new int[6];
  
  public static void main(String[] args) {
      for(int z=0; z&lt;5;z++) {
          Random i = new Random();
        //Change 10 to 60
          compnum[z]=i.nextInt((10 - 1) + 1) + 1;
      }
      System.out.println(" " + compnum[0] +"  " + compnum[1] +"  " + compnum[2] +"  " + compnum[3] +"  " + compnum[4]);
  
      while(nummatch[5]==0) {
          nextGo();
          matchFound=0;
          if(compnum[0]==displaynum[0]) {
              matchFound++;
          }
          if (compnum[1]==displaynum[1]){
              matchFound++;
          }
          if (compnum[2]==displaynum[2]){
              matchFound++;
          } 
          if (compnum[3]==displaynum[3]){
              matchFound++;
          }
          if (compnum[4]==displaynum[4]){
              matchFound++;
          }
          nummatch[matchFound]++;
      }
      System.out.println("  Zero Matches=" + nummatch[0] + "   One Matches=" + nummatch[1] +"   Two Matches=" +  nummatch[2]+ "   Three Matches=" + nummatch[3]+ "   Four Matches=" + nummatch[4]+ "   Total Draws=" + counter);
  
  }
  
  
  static void nextGo() {
      for(int x=0;x&lt;5;x++) {
          Random i = new Random();
          //Change 10 to 60
          displaynum[x]=i.nextInt((10 - 1) + 1) + 1;
      }
      counter++;
  
      System.out.println("  " + displaynum[0] +"  " + displaynum[1] +"  " + displaynum[2] +"  " + displaynum[3] +"  " + displaynum[4]);
  }
   }
  </code></pre>
  
  <p>So the above code shows each lotto drawing and displays the different matches properly. But I'm having trouble getting those same outputs to display in the GUI text fields.</p>
  
  <p>Here is my attempt at combining the above code and the GUI:</p>
  
  <pre><code>    package slots;
  
      import java.awt.*; 
      import java.awt.event.*; 
      import java.util.Random;
      import java.util.*;
  
    public class LottoGUI extends Frame implements ActionListener {
  
  private static TextField tfOne;
  private static TextField tfTwo;
  private static TextField tfThree;
  private static TextField tfFour;
  private static TextField tfFive;
  private Label lblmnZero;
  private static TextField mnZero;
  private Label lblmnOne;
  private static TextField mnOne;
  private Label lblmnTwo;
  private static TextField mnTwo;
  private Label lblmnThree;
  private static TextField mnThree;
  private Label lblmnFour;
  private static TextField mnFour;
  private Label lbltfDraws;
  private static TextField tfDraws;
  private Button btnGo;
  private Button btnClose;
  
  public LottoGUI() {
      setLayout(new FlowLayout());
  
        tfOne = new TextField("", 2);
        tfOne.setEditable(false);
        add(tfOne);
        tfTwo = new TextField("", 2);
        tfTwo.setEditable(false);
        add(tfTwo);
        tfThree = new TextField("", 2);
        tfThree.setEditable(false);
        add(tfThree);
        tfFour = new TextField("", 2);
        tfFour.setEditable(false);
        add(tfFour);
        tfFive = new TextField("", 2);
        tfFive.setEditable(false);
        add(tfFive);
  
        lblmnZero = new Label("Zero Matches:");
        add(lblmnZero);
        mnZero = new TextField("");
        mnZero.setEditable(false);
        add(mnZero);
        lblmnOne = new Label("One Matches:");
        add(lblmnOne);
        mnOne = new TextField("");
        mnOne.setEditable(false);
        add(mnOne);
        lblmnTwo = new Label("Two Matches:");
        add(lblmnTwo);
        mnTwo = new TextField("");
        mnTwo.setEditable(false);
        add(mnTwo);
        lblmnThree = new Label("Three Matches:");
        add(lblmnThree);
        mnThree = new TextField("");
        mnThree.setEditable(false);
        add(mnThree);
        lblmnFour = new Label("Four Matches:");
        add(lblmnFour);
        mnFour = new TextField("");
        mnFour.setEditable(false);
        add(mnFour);
        lbltfDraws = new Label("Total Draws:");
        add(lbltfDraws);
        tfDraws = new TextField("");
        tfDraws.setEditable(false);
        add(tfDraws);
  
        btnGo = new Button("GO");
        add(btnGo);
        btnClose = new Button("CLOSE");
        add(btnClose);
  
        btnGo.addActionListener(this);
        btnClose.addActionListener(this);
  
        setTitle("Lotto");
          setSize(1000, 100);
          setVisible(true);
  }
  
  public static void main(String[] args) {
      new LottoGUI();
  
  }
  
  public static class Slots {
      static int displaynum[] = new int[5];
      static int compnum[] = new int[5];
      static int counter=0;
      static int matchFound=0;
      static int nummatch[] = new int[6];
  
      public static void main(String[] args) {
          for(int z=0; z&lt;5;z++) {
              Random i = new Random();
            //Change 10 to 60
              compnum[z]=i.nextInt((10 - 1) + 1) + 1;
          }
          //System.out.println(" " + compnum[0] +"  " + compnum[1] +"  " + compnum[2] +"  " + compnum[3] +"  " + compnum[4]);
          Object[] obcm0 = {compnum[0]};
          mnZero.setText(Arrays.toString(obcm0));
          Object[] obcm1 = {compnum[1]};
          mnOne.setText(Arrays.toString(obcm1));
          Object[] obcm2 = {compnum[2]};
          mnTwo.setText(Arrays.toString(obcm2));
          Object[] obcm3 = {compnum[3]};
          mnThree.setText(Arrays.toString(obcm3));
          Object[] obcm4 = {compnum[4]};
          mnFour.setText(Arrays.toString(obcm4));
  
          while(nummatch[5]==0) {
              nextGo();
              matchFound=0;
              if(compnum[0]==displaynum[0]) {
                  matchFound++;
              }
              if (compnum[1]==displaynum[1]){
                  matchFound++;
              }
              if (compnum[2]==displaynum[2]){
                  matchFound++;
              } 
              if (compnum[3]==displaynum[3]){
                  matchFound++;
              }
              if (compnum[4]==displaynum[4]){
                  matchFound++;
              }
              nummatch[matchFound]++;
          }
          //System.out.println("  Zero Matches=" + nummatch[0] + "   One Matches=" + nummatch[1] +"   Two Matches=" +  nummatch[2]+ "   Three Matches=" + nummatch[3]+ "   Four Matches=" + nummatch[4]+ "   Total Draws=" + counter);
          Object[] obnm0 = {nummatch[0]};
          mnZero.setText(Arrays.toString(obnm0));
          Object[] obnm1 = {nummatch[1]};
          mnOne.setText(Arrays.toString(obnm1));
          Object[] obnm2 = {nummatch[2]};
          mnTwo.setText(Arrays.toString(obnm2));
          Object[] obnm3 = {nummatch[3]};
          mnThree.setText(Arrays.toString(obnm3));
          Object[] obnm4 = {nummatch[4]};
          mnFour.setText(Arrays.toString(obnm4));
          Object[] obcn = {counter};
          tfDraws.setText(Arrays.toString(obcn));
      }
  
  
      static void nextGo() {
          for(int x=0;x&lt;5;x++) {
              Random i = new Random();
              //Change 10 to 60
              displaynum[x]=i.nextInt((10 - 1) + 1) + 1;
          }
          counter++;
  
          //System.out.println("  " + displaynum[0] +"  " + displaynum[1] +"  " + displaynum[2] +"  " + displaynum[3] +"  " + displaynum[4]);
          Object[] obdn0 = {displaynum[0]};
          tfOne.setText(Arrays.toString(obdn0));
          Object[] obdn1 = {displaynum[1]};
          tfTwo.setText(Arrays.toString(obdn1));
          Object[] obdn2 = {displaynum[2]};
          tfThree.setText(Arrays.toString(obdn2));
          Object[] obdn3 = {displaynum[3]};
          tfFour.setText(Arrays.toString(obdn3));
          Object[] obdn4 = {displaynum[4]};
          tfFive.setText(Arrays.toString(obdn4));
      }
  }
  
  public void actionPerformed(ActionEvent e) {
      String str = e.getActionCommand();
  
       if(str.equals("GO"))
          new Slots();
  
       else if (str.equals("CLOSE"))
          System.exit(0);
      }
  
  }
  </code></pre>
  
  <p>Nothing happens when I click the "GO" button. Maybe I'm placing the print commands in the wrong section of the code or I'm not doing something else incorrectly? I'd really appreciate any guidance with this.</p>
  
  <p>This is also my first posting to this site so if I've messed up anything please let me know. I've been searching for help and can't find much that pertains to my issue. Thank you!</p>