private void joystick_switchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_joystick_switchActionPerformed
        //
        if (Controller.controllerPermission == true)
        {
            //
            Terminal.systemLogMessage("The joystick has been disconnected.");
            //
            Controller.firstReconnection=true;
            //
            joystick_switch.setText("Connect Joystick");
            //
            Controller.controllerPermission = false;
            //
            joystick_connection_state_label.setText("Disconnected");
            //
            joystick_connection_state_label.setForeground(Color.ORANGE);
            //
            try 
            {
                //
                Controller.joystick.close();
            } 
            //
            catch (USBException ex) 
            {
                //
            }
        }
        //
        //
        else if (Controller.controllerPermission == false)
        {
            //
            Controller.joystick = USB.getDevice((short) 0x068E, (short) 0x00CA);
            //
            try
            {
                //
                Controller.joystick.open(1,0,-1);
                //
                Controller.joystick.close();
                //
                if (Controller.firstReconnection==true)
                {
                    //
                    Terminal.systemLogMessage("The joystick has been re-connected.");
                    //
                    joystick_connection_state_label.setText("Connected");
                    //
                    joystick_connection_state_label.setForeground(Color.GREEN);
                }
                //
                else
                {
                    //
                    Terminal.systemLogMessage("The joystick has been connected.");
                    //
                    joystick_connection_state_label.setText("Connected");
                }
                //
                joystick_switch.setText("Disconnect Joystick");
                //
                joystick_connection_state_label.setForeground(Color.GREEN);
                //
                Controller.controllerPermission = true;
            }
            //
            catch (USBException ex)
            {
                //
                Terminal.systemLogMessage("The joystick USB is not plugged in.");
                joystick_connection_state_label.setText("Unplugged");
                //
                joystick_connection_state_label.setForeground(Color.RED);
                //
                Controller.controllerPermission=false;
                //
                UserInterface.joystick_switch.setText("Connect Joystick");
            }
        }
    }