I had posted a similar question before but it got deleted by accident.
My JTextField is supposed to appear after clicking a button which it does but only after minimizing the window. Another problem with it is that it accepts single characters when it's supposed to accept a phrase of only a certain length.
Here's a bit of the code since it's so long:
 static String answer = "MY PUZZLE", puzzle = "M- -U----"; 
  //inside constructor
  guess = new JTextField("Write in Caps");
  guess.setVisible(false); 
  guess.addActionListener(this);
  board.add(guess);
  //actionperformed
  guess.setVisible(true);
  gueStr = guess.getText();
  if (gueStr.length() != answer.length()) //if it is not the same length
  {
    gueStr = "";
  }
the String "puzzle" is changed if a letter button (code not shown here) that is a character from the "answer" String is pressed or if the user's guess is the same phrase as the answer String
  if ( gueStr.equals(answer)) //if the guess is the answer
  {
    puzzle = answer; 
  }
    for(int x=0; x < answer.length(); x++) //go through answer
    {
        if(letter == answer.charAt(x)) //if the letter pressed matches a character in answer
        {
          puzzle = puzzle.substring(0,x) + letter + puzzle.substring(x+1); //substitute in letter 
        }
    }
If more code is needed for understanding, I can post it. I'd be happy for a few pointers :D
Edit:
Thanks for all help guys, but I haven't been successful in understanding the second part yet.
Right now, I can get the textfield to show, but the problem lies with accepting a certain character length. It has to be the exact same length as another string, no more, no less.
I have tried implementing it with the links you guys gave but only ended up getting confused (sorry). Can someone please offer a specific example?
Edit:
Resolved after using validate() and adding guess.setActionCommand("1").