@Override
	public void actionPerformed(ActionEvent e)
	{
		if (e.getSource() == btnGenerate)
		{
			int w = 0, h = 0;
			try
			{
				w = Integer.parseInt(tfMazeWidth.getText());
				h = Integer.parseInt(tfMazeHeight.getText());

				if (w < 5 || h < 5)
				{
					throw new NumberFormatException();
				}
			} catch (NumberFormatException nfe)
			{
				tfMazeWidth.setText("" + main.getMazeWidth());
				tfMazeHeight.setText("" + main.getMazeHeight());
				return;
			}
			
			if(w % 2 == 0)
				w++;
			if(h % 2 == 0)
				h++;
			
			
			main.setMazeWidth(w);
			main.setMazeHeight(h);
			tfMazeWidth.setText("" + w);
			tfMazeHeight.setText("" + h);

			main.generate();
		} else if (e.getSource() == btnSolve)
		{
			main.solve();
		}
	}