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.
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 < dashes.length; i++){
txtDashes.setText(dashes[i]); //Error occurs here
} //End of for loop
I'm only experienced in about 5 months of java coding and can't seem to find a solution for this problem.