I am making a JFrame
for a card game.
I want to restart the JFrame
when the restartBtn
is clicked. Can anyone help me?
The PlayGame
class is to launch the frame1
public class PlayGame {
public static void main(String[] args) {
GameFrame frame1 = new GameFrame();
// Set Icon
Image icon = Toolkit.getDefaultToolkit().getImage("image/poker_icon.gif");
frame1.setIconImage(icon);
frame1.setVisible(true);
frame1.setSize(600, 700);
frame1.setTitle("Card Game");
// Set to exit on close
frame1.setDefaultCloseOperation(GameFrame.EXIT_ON_CLOSE);
}
}
This is the GameFrame
class is for the JFrame
constructor.
public class GameFrame extends JFrame implements ActionListener {
public JLabel restartLbl;
public JButton restartBtn
public GameFrame() {
restartLbl = new JLabel(restart);
restartBtn = new JButton();
restartBtn..addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == restartBtn) {
}
}
}