hello I'm having a problem with this tic tac toe game that i am making. what is happening is that the game is suppose to reset when ether a person wins or there is a tie. so far it only exits and dose not reset the game. any suggestions on how to fix this problem?
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TicTakToe extends JFrame { private JMenuBar bar = new JMenuBar(); private JMenu file = new JMenu("File"); private JMenuItem exit = new JMenuItem("exit"); private static boolean win = false; private String letter = ""; private int count = 0; private JButton a1 = new JButton(""); private JButton a2 = new JButton(""); private JButton a3 = new JButton(""); private JButton b1 = new JButton(""); private JButton b2 = new JButton(""); private JButton b3 = new JButton(""); private JButton c1 = new JButton(""); private JButton c2 = new JButton(""); private JButton c3 = new JButton(""); public class exit implements ActionListener { public void actionPerformed(ActionEvent e) { System.exit(0); } } public class test implements ActionListener { public void actionPerformed(ActionEvent e2) { count++; if(count == 1 || count == 3 || count == 5 || count == 7 || count == 9) { letter = "X"; } else if(count == 2 || count == 4 || count == 6 || count == 8 || count == 10) { letter = "O"; } if(e2.getSource() == a1) { a1.setText(letter); a1.setEnabled(false); } else if(e2.getSource() == a2) { a2.setText(letter); a2.setEnabled(false); } else if(e2.getSource() == a3) { a3.setText(letter); a3.setEnabled(false); } else if(e2.getSource() == b1) { b1.setText(letter); b1.setEnabled(false); } else if(e2.getSource() == b2) { b2.setText(letter); b2.setEnabled(false); } else if(e2.getSource() ==b3) { b3.setText(letter); b3.setEnabled(false); } else if(e2.getSource() == c1) { c1.setText(letter); c1.setEnabled(false); } else if(e2.getSource() == c2) { c2.setText(letter); c2.setEnabled(false); } else if(e2.getSource() == c3) { c3.setText(letter); c3.setEnabled(false); } if( a1.getText() == a2.getText() && a2.getText() == a3.getText() && a1.getText() != "" || b1.getText() == b2.getText() && b2.getText() == b3.getText() && b1.getText() != ""|| c1.getText() == c2.getText() && c2.getText() == c3.getText() && c1.getText() != "") { win = true; } else if(a1.getText() == b1.getText() && b1.getText() == c1.getText() && a1.getText() != "" || a2.getText() == b2.getText() && b2.getText() == c2.getText() && a2.getText() != ""|| a3.getText() == b3.getText() && b3.getText() == c3.getText() && a3.getText() != "") { win = true; } else if(a1.getText() == b2.getText() && b2.getText() == c3.getText() && a1.getText() != "" || a3.getText() == b2.getText() && b2.getText() == c1.getText() && a3.getText() != "") { win = true; } else { win = false; } // these are the lines that should reset the game. if(win == true) { JOptionPane.showMessageDialog(null, letter + " wins the game!"); System.exit(0); } else if(count == 9 && win == false) { System.exit(0); } //======================== } } public TicTakToe() { LayoutManager some_layout = new BorderLayout(); setLayout(some_layout); add(bar, BorderLayout.NORTH); bar.add(file); file.add(exit); exit close = new exit(); test c = new test(); exit.addActionListener(close); a1.addActionListener(c); a2.addActionListener(c); a3.addActionListener(c); b1.addActionListener(c); b2.addActionListener(c); b3.addActionListener(c); c1.addActionListener(c); c2.addActionListener(c); c3.addActionListener(c); JPanel cen_panel = new JPanel(); LayoutManager some_layout2 = new GridLayout(3,3); cen_panel.setLayout(some_layout2); cen_panel.add(a1); cen_panel.add(a2); cen_panel.add(a3); cen_panel.add(b1); cen_panel.add(b2); cen_panel.add(b3); cen_panel.add(c1); cen_panel.add(c2); cen_panel.add(c3); add(cen_panel,BorderLayout.CENTER); setTitle("test"); setSize(400,400); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public static void main(String[] args) { TicTakToe test = new TicTakToe(); } }