title: how to make my reset button work
body: <p>I'm writing a code which generates a random maze, every time i run the program it looks diffrent, but i cant get my reset button working. Here is some of my code:</p>
  
  <pre><code>public class MakeFrame extends JPanel implements ActionListener {
  
  JFrame frame;
  JPanel buttonPanel;
  JButton solve1;
  JButton solve2;
  JButton solve3;
  JButton clear;
  JButton reset;
  Maze maze = new Maze();
  
  void buildframe() {
      frame = new JFrame("maze"); //makes a frame, names it maze
      frame.add(this, BorderLayout.CENTER);
      frame.add(maze);
  
      buttonPanel = new JPanel();
      frame.add(buttonPanel, BorderLayout.NORTH);
      solve1 = new JButton("solve 1"); // create some buttons
      solve2 = new JButton("solve 2");
      solve3 = new JButton("solve 3");
      clear = new JButton("clear");
      reset = new JButton("reset");
  
      buttonPanel.add(solve1); // add the buttons to a panel
      buttonPanel.add(solve2);
      buttonPanel.add(solve3);
      buttonPanel.add(clear);
      buttonPanel.add(reset);
  
      solve1.addActionListener(this);// assigns action listeners to buttons
      solve2.addActionListener(this);
      solve3.addActionListener(this);
      clear.addActionListener(this);
      reset.addActionListener(this);
  
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // makes the frame visable, grey and close on exit.
      frame.setSize(455, 320);
      frame.setVisible(true);
      setBackground(Color.GRAY);
  
  }
  
  @Override
  
   public void actionPerformed(ActionEvent e) {
      if (e.getSource() == reset) {
     frame.add(new Maze());
     repaint();
  
  
  
      }
  }
  }
  </code></pre>
  
  <p>I don't know what to put in the action performed method to make it work, can anybody help me?</p>
  
  <p>here is my class maze:</p>
  
  <pre><code>public class Maze extends JPanel {
  
  Cell[][] cells = new Cell[22][12];
  String[][] route = new String[22][12];
  Random random = new Random();
  
  Maze() {
      othersetroute();
      createFloor();
  
      createWalls();
      setStartEnd();
  }
  
  
  
  void othersetroute() {
      int x = 1;
      int y = 1;
      int downorright;
      for (int i = 0; i &lt; 50; i++) {
          downorright = random.nextInt(3);
          if (x == 20 &amp;&amp; y == 10) {
              break;
          }
          if (x &gt; 20 || y &gt; 10) {
              break;
          }
          if (y == 10 || downorright == 0 || downorright == 1) {
              x++;
          } else {
              y++;
          }
          route[x][y] = "floor";
      }
      for (int a = 0; a &lt; 22; a++) {
          for (int b = 0; b &lt; 12; b++) {
  
              if (route[a][b] == null) {
                  int floororwall;
                  floororwall = random.nextInt(4);
                  if (floororwall == 0 || floororwall == 1) {
                      route[a][b] = "walls";
                  } else {
                      route[a][b] = "floor";
                  }
                  if (a % 2 == 1 &amp;&amp; b % 2 == 1) {
                      route[a][b] = "floor";
                  }
                  if (a % 2 == 0 &amp;&amp; b % 2 == 0) {
                      route[a][b] = "walls";
                  }
  
              }
          }
      }
  
  }
  
  void setRoute() {
      int x = 1;
      int y = 1;
      int leftcounter = 0;
      int rightcounter = 0;
      int upcounter = 0;
      int downcounter = 0;
  
      for (int i = 0; i &lt; 150; i++) {
  
          String direction;
          if (x &gt; 20 || y &gt; 10) {
              break;
          } else if (x == 20 &amp;&amp; y == 10) {
              break;
          } else if (downcounter == 14 &amp;&amp; upcounter == 5 &amp;&amp; leftcounter == 10 &amp;&amp; rightcounter == 29) {
              break;
          } else if (x == 20) {
              int k = random.nextInt(3);
              if (k == 0) {
                  direction = "left";
              } else if (k == 1) {
                  direction = "up";
              } else {
                  direction = "down";
              }
  
          } else if (y == 10) {
              int k = random.nextInt(3);
              if (k == 0) {
                  direction = "left";
              } else if (k == 1) {
                  direction = "up";
              } else {
                  direction = "right";
              }
          } else if (x == 1 || y == 1) {
              int k = random.nextInt(3);
              if (k == 0) {
                  direction = "down";
              } else {
                  direction = "right";
              }
  
          } else {
              int k = random.nextInt(4);
              if (k == 0) {
                  direction = "left";
              } else if (k == 1) {
                  direction = "up";
              } else if (k == 2) {
                  direction = "right";
              } else {
                  direction = "down";
              }
          }
          if (direction.equals("right") &amp;&amp; rightcounter &lt; 30) {
              x++;
              rightcounter++;
          } else if (direction.equals("down") &amp;&amp; downcounter &lt; 15) {
              y++;
              downcounter++;
          } else if (direction.equals("left") &amp;&amp; leftcounter &lt; 11) {
              x = x - 1;
              leftcounter++;
          } else if (direction.equals("up") &amp;&amp; upcounter &lt; 6) {
              y = y - 1;
              upcounter++;
          }
          System.out.println(x);
          System.out.println(y);
          route[x][y] = "floor";
  
      }
      for (int a = 0; a &lt; 22; a++) {
          for (int b = 0; b &lt; 12; b++) {
  
              if (route[a][b] == null) {
                  int floororwall;
                  floororwall = random.nextInt(4);
                  if (floororwall == 0 || floororwall == 1) {
                      route[a][b] = "walls";
                  } else {
                      route[a][b] = "floor";
                  }
                  if (a % 2 == 1 &amp;&amp; b % 2 == 1) {
                      route[a][b] = "floor";
                  }
                  if (a % 2 == 0 &amp;&amp; b % 2 == 0) {
                      route[a][b] = "walls";
                  }
  
              }
          }
      }
  }
  
  void createFloor() {
      for (int x = 0; x &lt; 22; x++) {
          for (int y = 0; y &lt; 12; y++) {
              if (route[x][y].equals("walls")) {
                  cells[x][y] = new Cell("walls");
              }
              if (route[x][y].equals("floor")) {
                  cells[x][y] = new Cell("floor");
  
              }
          }
      }
  }
  
  void createWalls() {
  
      for (int i = 0; i &lt; 12; i++) {
          cells[0][i] = new Cell("walls");
  
          cells[21][i] = new Cell("walls");
      }
      for (int i = 0; i &lt; 22; i++) {
          cells[i][0] = new Cell("walls");
          cells[i][11] = new Cell("walls");
      }
      for (int x = 0; x &lt; 22; x++) {
          for (int y = 0; y &lt; 12; y++) {
              if (cells[x][y] == null) {
                  cells[x][y] = new Cell("walls");
  
              }
          }
      }
  }
  
  void setStartEnd() {
  
      cells[1][1] = new Cell("start");
      cells[20][10] = new Cell("end");
  }
  
  @Override
  public void paintComponent(Graphics g) {
  
      for (int x = 0; x &lt; 22; x++) {
          for (int y = 0; y &lt; 12; y++) {
              if (cells[x][y].getType().equals("#")) {
                  g.setColor(Color.GREEN);
                  g.fillRect(x * 20, y * 20, x * 20 + 20, y * 20 + 20);
              }
              if (cells[x][y].getType().equals(" ")) {
                  g.setColor(Color.WHITE);
                  g.fillRect(x * 20, y * 20, x * 20 + 20, y * 20 + 20);
              }
              if (cells[x][y].getType().equals("S") || cells[x][y].getType().equals("E")) {
                  g.setColor(Color.PINK);
                  g.fillRect(x * 20, y * 20, x * 20 + 20, y * 20 + 20);
              }
          }
      }
  
  }
  void solutionOne(){ // least visited
      int visits[][]= new int [20][10];
      for (int i = 0; i&lt;21; i++){
          for (int j = 0; j&lt;10; j++){
              visits[i][j]=0;
          }
      }
      for (int i = 0; i&lt;100; i++){
  
      }
  
  }
  }
  </code></pre>
  
  <p>and here is my class cell :p</p>
  
  <pre><code>public class Cell {
  private String cell;
  
  Cell(String type){
      if (type.equals("walls")){
          walls();
      }
      if (type.equals("floor")){
          Floor();
      }
      if (type.equals("start")){
          start();
      }
      if(type.equals("end")){
          end();
      }
  }
  void walls(){
      cell = "#";
  }
  void start(){
      cell = "S";
  }
  void end(){
      cell = "E";
  }
  void Floor(){
      cell = " ";
  }
  
  
  public String getType(){
  return cell;
  }
  
  
  
  }
  </code></pre>