/** * Is called from the model when data is changed, updates members and view of this class. Checks * if the game is over. * * @param e ChangeEvent object */ public void stateChanged(ChangeEvent e) { // update the view: accessors and repaint data = model.getData(); repaint(); if (model.isFinish() && !gameOver) { gameOver = true; JFrame frame = new JFrame("Declare Winner"); if (model.declareWinner() == 1) JOptionPane.showMessageDialog(frame, "A is the winner!!!"); else if (model.declareWinner() == 2) JOptionPane.showMessageDialog(frame, "B is the winner!!!"); else JOptionPane.showMessageDialog(frame, "It is a tie!!!"); } }