public void restartGame() {
        //Make a new thread to ensure we don't run it on the EDT

        new Thread() {
            public void run() {
                if (panel != null) {
                    panel.removeComponentListener(panel);
                    panel.removeMouseMotionListener(panel);
                    panel.removeMouseListener(panel);
                    frame.remove(panel);
                }

                game = new CardGame(CardFrame.this);
                panel = new CardPanel(game);

                frame.add(panel, BorderLayout.CENTER);
                frame.pack();
                frame.setVisible(true);
                frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
                //  frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
                startGame();
            }

        }.start();
    }