I am creating a hangman game using a java gui. I was wondering how to add a JLabel to an array list and to a JPanel. The problem is that the JLabels have to be added according to the length of the word. I don't know how to add a JLabel if it doesn't have a predefined name. The code is below:
for(int x = 1; x <= selectedWord.wordLength; x++){
wordSpacesPanel.add(new JLabel("? "));
}
If you need more than the above code just ask. Any help is appreciated as I have been trying to figure this out for a few hours. Thanks Again.