title: How to Convert Applet to JFrame
body: <p>This is Our code for our game. we had it as an applet viewer before and we tried converting to jframe but it keeps giving us <code>ClassCastException</code> errors. Please help us convert from applet to jframe. Here's the code and tell us what to do?</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  
  import javax.swing.JButton;
  import javax.swing.*;
  
  
  public class gg extends JFrame implements MouseListener
  {   
      private JButton table[][];     
      //private boolean bomb[][];    
  //  private boolean flag[][];      
      private boolean exposed[][]; 
      //private boolean checkwinbool[][]; 
      private int row = 16, col = 30; 
      private int sizex = 780, sizey = 492;
      private Font f ;
      private JPanel P;
      private JLabel TimeRemaning, NG;
      private JButton RestartE, RestartM, RestartH;
      private GridLayout gl;
  
  
  
      public gg() {
  
          setLayout (new BorderLayout ());
          gl = new GridLayout (row, col);
          P = new JPanel (gl);
          f = new Font ("ComicSans", Font.BOLD, 17);
          setFont (f);
          TimeRemaning = new JLabel ("");
          NG = new JLabel ("New Game");
          RestartE = new JButton ("Easy");
  
  
          table = new JButton [row] [col];
          //flag = new boolean [row] [col];
          exposed = new boolean [row] [col];
          //checkwinbool = new boolean [row] [col];
          for (int x = 0 ; x &lt; row ; x++)
          {
              for (int y = 0 ; y &lt; col ; y++)
              {
                  table [x] [y] = new JButton ();
                  table [x] [y].addMouseListener (this);
                  P.add (table [x] [y]);
              }
          }
          //these for loops set up the buttons and sets all the boolean arrays to = false
  
          add (P, "Center");
          NG.setBackground(Color.lightGray);
          NG.setForeground(Color.black);
          Restart_Game (row, col, row, col, sizex, sizey);
  
  
  
      }
  
  
      public void Restart_Game (int row, int col, int prow, int pcol, int sizex, int sizey)
      {
  
          setSize (sizex, sizey);
          invalidate();
          validate();
          gl.setRows (row);
          gl.setColumns (col);
  
          for (int x = 0 ; x &lt; prow ; x++)
          {
              for (int y = 0 ; y &lt; pcol ; y++)
              {
                  P.remove (table [x] [y]);
              }
          }
          for (int x = 0 ; x &lt; row ; x++)
          {
              for (int y = 0 ; y &lt; col ; y++)
              {
  
                  table [x] [y].setEnabled (true);
  
                  table [x] [y].setBackground (Color.gray);
                  table [x] [y].setForeground (Color.white);
                  P.add (table [x] [y]);
                  //flag [x] [y] = false;
                  exposed [x] [y] = false;
                  //checkwinbool [x] [y] = false;
              }
          }
          setSize (sizex, sizey);
          invalidate();
          validate();
  
  
      }
  
  
      public void mouseClicked (MouseEvent e)
      {
          if (e.getSource () == RestartE)
          {
              row = 10;
              col = 10;
              sizex = 300;
              sizey = 346;
          }
      }
  </code></pre>
  
  <ol>
  <li><p>List item</p>
  
  <pre><code>public void mousePressed(MouseEvent e) {}
  public void mouseReleased(MouseEvent e) {}
  public void mouseEntered(MouseEvent e) {    }
  public void mouseExited(MouseEvent e) {}}
  </code></pre></li>
  </ol>