title: java - How do I display a character array in a JTextField
body: <p>I'm trying to create a hangman game where dashes will display for the user and if they click on the correct button, a letter will replace the dashes. This worked when I was using the console to output all the data, but after I changed to GUI, it wouldn't work no matter what I tried. It seems that the JTextField won't accept a character array.</p>
  
  <pre><code>    private static JTextField txtDashes;
      static char [] dashes = {'-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'};
  
              txtDashes = new JTextField();
              txtDashes.setBackground(Color.GRAY);
              txtDashes.setHorizontalAlignment(SwingConstants.CENTER);
              txtDashes.setBorder(javax.swing.BorderFactory.createEmptyBorder());
              txtDashes.setBounds(39, 207, 218, 46);
              gameScreen.add(txtDashes);
              txtDashes.setColumns(10);
  
              for (int i = 0; i &lt; dashes.length; i++){
                     txtDashes.setText(dashes[i]); //Error occurs here
              } //End of for loop
  </code></pre>
  
  <p>I'm only experienced in about 5 months of java coding and can't seem to find a solution for this problem. </p>