public void stopSimulation(java.awt.event.ActionEvent evt) {
        setEnabledButtons((JButton) evt.getSource(), buttonGroup1, true);
        this.txtClock.setText("0");
        if (simulator != null) {
            simulator.setStop(true);
            while (simulator.isAlive()) {
            }

            simulator = null;
            this.btnStop.setVisible(false);
            NetClass n = new NetClass();
            try {
                n.compile(javaSource);
            } catch (Exception e) {
                FrmViewSource jform = new FrmViewSource(JOptionPane.getFrameForComponent(this), true, e.getMessage(), "Compilation Errors");
                jform.setVisible(true);
                Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, e);
            }

            canvas.repaint();
        }
    }