private void cmd_disconnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmd_disconnectActionPerformed
        try {
            cl.out.writeUTF(txt_username.getText()+":/logoffuser");
            cl.out.flush();
            cl.socket.close();
            //enable needed components
            cmd_regNewUser.setEnabled(true);
            txt_username.setEnabled(true);
            txt_password.setEnabled(true);
            cmd_connect.setEnabled(true);

            //disable elements not needed for the chat
            cmd_disconnect.setEnabled(false);
            cmd_send.setEnabled(false);
            txt_sendingField.setEnabled(false);
            tabpanel_chathistory.setEnabled(false);
            lbx_users_online.setEnabled(false);
            txt_chatHistory.setEnabled(false);

            txt_sendingField.setText("Enter message here...");

            System.out.println("Disconnected from server! Reason: user disconnect");
        } catch (IOException ex) {
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_cmd_disconnectActionPerformed