Jump to content

[SOLVED]Removing a Jpanel and re-adding it

- - - - -

  • Please log in to reply
No replies to this topic

#1
mariob316

mariob316

    Newbie

  • Members
  • Pip
  • 8 posts
Im almost done my tictactoe game. The thing is, once someone wins a new JPanel shows up in the north with 2 buttons "Play again" or "Exit". If you click Play again i got it to remove the TicTacToe panel (which is in the center) but when i re-add the panel it re-adds it but in the state of the last player who won. It doesn't start fresh. Here's the code i have for the actionEvent for the button Play again

c is the container

btnPlayAgain.addActionListener(new ActionListener() {


            public void actionPerformed(ActionEvent e) {

                if (e.getActionCommand().equals("PlayAgain")) {

                   c.remove(panelTicTacToe);

                   c.repaint();

                   c.add(panelTicTacToe);

                   

                }

            }

        });

anyway of Updating the panel back like when the game first starts?

Edited by mariob316, 06 December 2010 - 09:08 PM.
Got it





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users