@Override
			public void mouseClicked(MouseEvent e) {

				SwingWorker<Solution, Void> worker = new SwingWorker<Solution, Void>() {

					Solver solver;
					long searchTime;

					@Override
					protected Solution doInBackground() throws Exception {
						solveButton.setText("Solving...");
						solveButton.setEnabled(false);
						setAlgorithm();
						solver = new Solver(puzzle, algorithm);
						long startTime = System.nanoTime();
						Solution solution = solver.solve();
						searchTime = System.nanoTime() - startTime;
						return solution;
					}

					private void setAlgorithm() {
						String heu = heuristicComboBox.getSelectedItem()
								.toString();
						if (heu.equals("Manhattan")) {
							heuristic = new ManhattanHeuristic(N);
						} else if (heu.equals("Misplaced")) {
							heuristic = new MisplacedHeuristic(N);
						}
						String alg = algorithmComboBox.getSelectedItem()
								.toString();
						if (alg.equals("Breadth First Search")) {
							heuristicComboBox.setEnabled(false);
							algorithm = new BreadthFirstSearch();
						} else if (alg.equals("Iterative DLS")) {
							heuristicComboBox.setEnabled(false);
							algorithm = new IterativeDLS();
						} else {
							heuristicComboBox.setEnabled(true);
							if (alg.equals("A*")) {
								algorithm = new AStar(heuristic);
							} else if (alg.equals("IDA*")) {
								algorithm = new IDAStar(heuristic);
							} else if (alg.equals("Weighted A*")) {
								algorithm = new WeightedAStar(heuristic,
										Integer.parseInt(weightTextField
												.getText()));
							}
						}
					}

					@Override
					protected void done() {
						try {
							solveButton.setText("Solve");
							textArea.append(get().toString() + "\n");
						} catch (InterruptedException | ExecutionException ex) {
							ex.printStackTrace();
						}
						textArea.append("Search finished with "
								+ algorithm.toString()
								+ " algorithms "
								+ ((heuristicComboBox.isEnabled()) ? ("with "
										+ heuristic.toString() + " heuristics\n")
										: "") + "in approximately: "
								+ (searchTime / 1000000000.0) + "s");
						if (logBox.isSelected()) {
							try {
								createLogFile(get());
							} catch (InterruptedException | ExecutionException e) {
								e.printStackTrace();
							}
						}
					}
				};

				if (solveButton.isEnabled())
					worker.execute();
			}