#How can I null this frame even though it was declared in a different method?

3 messages · Page 1 of 1 (latest)

livid thistle
#

I’m currently trying to make a hangman game and the chunk of code I’m stuck on is this:

public static void gameFrame(){
welcomeFrame.setVisible(false);
JFrame gFrame;
JPanel gPanel;
gFrame = new JFrame("Hangman");
gPanel = new JPanel();
gFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gFrame.setLayout(null);
gFrame.add(gPanel);
gFrame.setSize(400,250);
gFrame.setVisible(true);
}
}

It says welcomeFrame is an undeclared variable even though I declared it in a separate public method. When I try to declare it in the class, it gives me an error regarding static context. What should I do here?

dawn dew
#

Could you share your full code?

livid thistle
#

it’s ok! i remedied it