I have a simple JPanel for tic-tac-toe, line drawing ... so the TTT class extends JPanel and contains a GameLogic object inside.
all is well, the JFrame application in Main adds TTT and all is good.
BUT, when I want to restart a new game,
I call "reboot" in my TTT, which basiclly does: gameLogic = new GameLogic (); and redraw ();
now my dataset is clean and it should only draw rows.
in any way, Windows does not change at all.
I tried everything with no luck. Any suggestions?
GameBoard.java:
public class GameBoard extends javax.swing.JPanel {
private GameBoardLogic GameLogic;
public void Restart()
{
GameLogic = new GameBoardLogic();
removeAll();
repaint();
}
Main.java:
public class Main {
private static GameBoard TTT;
private static JFrame application;
public static void main(String[] args) {
application = new JFrame("Tic-Tac-Tow");
TTT = new GameBoard();
application.add(TTT);
application.setSize(350, 350);
application.setVisible(true);
if ( JOptionPane.showConfirmDialog(null, "Do you want to play again?") ==
JOptionPane.YES_OPTION )
{
application.removeAll();
TTT.Restart();
application.add(TTT);
application.validate();
}
source
share