title: Thread output to GUI Text Field
body: <p>I am trying to have the output in a TextField in a GUI but all I am getting is the thread information. This is just a small set from the full code but the full version has the same problem. The full version has 5 different threads running at the same time. Any help or advice would be appreciated.</p>
  
  <pre><code>public class O21 implements Runnable {
  @Override
  public void run() {
  
      try {
          Scanner O1 = new Scanner(new File("O21.txt"));
          O1.useDelimiter(",");
          while (O1.hasNext()) {
              String a = O1.next();
              int aa = Integer.parseInt(a);
              Thread.sleep(500); // Time delay to sync output
              if (a.trim().isEmpty()) {
                  continue;
              }
              System.out.println(a);
          }
      } catch (Exception f) {
          f.printStackTrace();
      }}}
  </code></pre>
  
  <p>This is the main.</p>
  
  <pre><code>public class Window {
      private JFrame frmTest;
      private JTextField txtTank1;
      private JTextField textField_4;
      static String o1;
  
  /**
   * Launch the application.
   */
  public static void main(String[] args) throws Exception {
  
      Thread a = new Thread(new O21());
      a.start();
  
      o1= a.toString();
  
      EventQueue.invokeLater(new Runnable() {
          public void run() {
              try {
                  Window window = new Window();
                  window.frmTest.setVisible(true);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
  
      });
  }
  
  /**
   * Create the application.
   */
  public Window() {
      initialize();
  }
  
  /**
   * Initialize the contents of the frame.
   */
  private void initialize() {
      frmTest = new JFrame();
      frmTest.setAlwaysOnTop(true);
      frmTest.setResizable(false);
      frmTest.setBounds(100, 100, 350, 400);
      frmTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frmTest.getContentPane().setLayout(null);
  
      txtTank1 = new JTextField();
      txtTank1.setText("Tank1");
      txtTank1.setFont(new Font("Tahoma", Font.PLAIN, 20));
      txtTank1.setEditable(false);
      txtTank1.setColumns(10);
      txtTank1.setBounds(10, 60, 150, 50);
      frmTest.getContentPane().add(txtTank1);
  
      textField_4 = new JTextField();
      textField_4.setEditable(true);
      textField_4.setText(o1);
      textField_4.setFont(new Font("Tahoma", Font.PLAIN, 20));
      textField_4.setColumns(10);
      textField_4.setBounds(170, 60, 150, 50);
      frmTest.getContentPane().add(textField_4);
  }}
  </code></pre>