private void toggleDebugger(JMenuItem src, Class<?> listener) {
        Bot b = window.getActiveBot();
        if (b != null) {
            HijackCanvas c = b.getCanvas();
            boolean removed = false;
            if (c == null) {
                b.getLogger().log(new LogRecord(Level.SEVERE, "Error accessing canvas..."));
                return;
            }
            for (int i = 0; i < c.getListeners().size(); i++) {
                ProjectionListener pl = c.getListeners().get(i);
                if (pl.getClass().equals(listener)) {
                    Debugger d = (Debugger) pl;
                    d.uninstall();
                    c.getListeners().remove(i);
                    removed = true;
                    src.setIcon(null);
                    b.getLogger().log(new LogRecord(Level.FINE, "Uninstalled " + d.getClass().getSimpleName().replaceAll("Debug", "") + " debugger"));
                    break;
                }
            }

            if (!removed) {
                try {
                    Debugger d = (Debugger) listener.newInstance();
                    d.install(b);
                    c.getListeners().add(d);
                    src.setIcon(tickIcon);
                    b.getLogger().log(new LogRecord(Level.FINE, "Installed " + d.getClass().getSimpleName().replaceAll("Debug", "") + " debugger"));
                } catch (InstantiationException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }