title: How to make Jbutton run another class?
body: <p>Hi stackoverflow community!</p>
  
  <p>I'm making an AI TicTacToe project for my finals, and I'm having a problem trying to run another class after pressing one of jButtons in the jFrame class.</p>
  
  <p>I'm using NetBean's jFrame class, where you can design easily by placing it from the container, and some of the codes are not editable.</p>
  
  <p>What I want to make is a workable Main Menu (which is a jFrame class) for my gaming project, and it contains three buttons which are Normal, Large and Extra Large. For Normal button, I want to make this button to run TicTacToe (which is a normal java class) after being pressed, but for some reasons I can't make it work. Here are the codes:</p>
  
  <p><em>MainMenu.java</em>                      </p>
  
  <pre><code>private void ButtonNormal(java.awt.event.ActionEvent evt) {                              
      // TODO add your handling code here:
      Normal_TicTacToe SIZE1 = new Normal_TicTacToe();  // This is the problem
      SIZE1.setVisible(true);                             
  }
  /**
   * @param args the command line arguments
   */
  public static void main(String args[]) {
      /* Create and display the form */
      java.awt.EventQueue.invokeLater(new Runnable() 
      {
          public void run()
          {
              new MainMenu().setVisible(true);
          }
      });
  }
  
  // Variables declaration - do not modify                     
  private javax.swing.JButton buttonNormal;
  // End of variables declaration                   
  }
  </code></pre>
  
  <p><i>Normal_TicTacToe.java</i> - I got this code from the internet, and I'm modifying it for Large and Extra Large size. I'll credit this guy as the original author in the documentation.</p>
  
  <pre><code>public final class Normal_TicTacToe extends JApplet 
  {
  
  private static final long serialVersionUID = 1L;
  private final Normal_Tile[] TILES = new Normal_Tile[9];
  private final int TILE_SPACING = 96;
  private final int WIDTH = 96, HEIGHT = 96;
  private final JFrame GAMEFRAME = new JFrame("Tic-Tac-Toe");
  private final Normal_TilePainter PAINTER = new Normal_TilePainter(this);
  private final Normal_ClickHandler CLICK_HANDLER = new Normal_ClickHandler(this);
  private final boolean AI;
  private boolean aiTurn = false;
  private Normal_Holder turn = Normal_Holder.X;
  private int whoseTurn = 0;
  private final Dimension FRAME_SIZE = new Dimension(295, 304);
  private final int FONT_SIZE = 64;
  private int oWins = 0;
  private int xWins = 0;
  private boolean gameOver = false;
  private boolean nextTurn = false;
  public final Normal_AI GAME_AI = new Normal_AI(this);
  
  public void init() 
  {
      Normal_TicTacToe game = new Normal_TicTacToe(true);
  game.newGame();
  }
  
  public Normal_TicTacToe(boolean ai) 
  {
      this.AI = ai;
      PAINTER.setSize(FRAME_SIZE);
      buildFrame();
      loadTiles();
  }
  </code></pre>
  
  <p>Also, both java files are in the same package.</p>
  
  <p>If you're looking for extended codes and all the java files, you can find it here:<br>
  <a href="http://pastebin.com/rtXwub0b" rel="nofollow">My MainMenu.java</a><br>
  <a href="http://forum.codecall.net/topic/72378-java-tutorial-tictactoe-revised/" rel="nofollow">Chall's TicTacToe and his java files</a> (Scroll down until you see source files).</p>