/* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   *  Invoked when an action occurs.
   */
  public void actionPerformed(ActionEvent e) {
    String actionCmd = e.getActionCommand();
    myConnections =
        Gui.dispatcher.sortConnections(Gui.dispatcher.getAllConnections(), Gui.myLib).toArray();

    if (actionCmd.equals("cancel")) {
      this.dispose();
    }

    if (actionCmd.equals("ok")) {

      if (languages.getSelectedItem().toString() == Gui.lang.getString("german")) {
        // System.out.println(languages.getSelectedItem().toString()+"deustch");

        Configurator.setProperty("language", "german", "gui-options");
        Gui.language = "german";

        // Gui.lang = Gui.dispatcher.initLanguage(Locale.GERMAN);

      } else {
        // System.out.println(languages.getSelectedItem().toString()+"english");

        Configurator.setProperty("language", "english", "gui-options");
        Gui.language = "english";
      }

      if (box1.isSelected()) {
        Configurator.setProperty("toolbar", Integer.toString(1), "gui-options");
        Gui.toolbar.setVisible(true);
        Gui.modalParent.update(Gui.modalParent.getGraphics());
        Gui.showToolbar = true;
      } else {

        Configurator.setProperty("toolbar", "0", "gui-options");

        Gui.toolbar.setVisible(false);
        Gui.modalParent.update(Gui.modalParent.getGraphics());
        Gui.showToolbar = false;
      }
      if (box2.isSelected()) {
        Configurator.setProperty("warnings", "1", "gui-options");
        Gui.showWarnings = true;
      } else {
        Configurator.setProperty("warnings", "0", "gui-options");
        Gui.showWarnings = false;
      }
      if (box4.isSelected()) {
        Configurator.setProperty("confirmations", "1", "gui-options");
        Gui.showConfirmations = true;
      } else {
        Configurator.setProperty("confirmations", "0", "gui-options");
        Gui.showConfirmations = false;
      }
      if (box3.isSelected()) {
        Configurator.setProperty("connect", "1", "gui-options");
        Gui.connect = true;
        ToolBar.connectButton.setSelected(true);
        Menu.connect.setSelected(true);
        ArrayList connectedLibs = new ArrayList();
        for (int i = 0; i < this.myConnections.length; i++) {
          System.out.println("Connect");
          Connection conn = (Connection) myConnections[i];
          connectedLibs.add(Gui.dispatcher.connect(conn));
        }

        ToolBar.connectButton.setToolTipText(Gui.lang.getString("connected"));
      } else {
        Configurator.setProperty("connect", "0", "gui-options");
        Gui.connect = false;
        ToolBar.connectButton.setSelected(false);
        Menu.connect.setSelected(false);
        ToolBar.connectButton.setToolTipText(Gui.lang.getString("not_connected"));
        Gui.dispatcher.disconnectFromAllConnectedLibraries();
      }

      if (box5.isSelected()) {
        Configurator.setProperty("update", "1", "gui-options");
        Gui.automaticUpdate = true;
      } else {
        Configurator.setProperty("update", "0", "gui-options");
        Gui.automaticUpdate = false;
      }

      Configurator.store();
      this.dispose();
    }
  }