Esempio n. 1
0
 public void actionPerformed(ActionEvent e) {
   int index = list.getSelectedIndex();
   if ("Move".equals(e.getActionCommand())) {
     copy = false;
     directoryList.getDirectory(index).copy = false;
   }
   if ("Copy".equals(e.getActionCommand())) {
     copy = true;
     directoryList.getDirectory(index).copy = true;
   }
 }
 /** Effectue differentes actions en fonction du bouton que l'on clique */
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().equals("Réinitialiser")) {
     this.maGrille.viderTabCases();
   } else if (e.getActionCommand().equals("Aléatoire")) {
     this.maGrille.remplirAleatTabCases();
   } else if (e.getActionCommand().equals("Chemin")) {
     this.etat = (byte) 0;
     this.indication.setEtat((byte) 0);
   } else if (e.getActionCommand().equals("Mur")) {
     this.etat = (byte) 1;
     this.indication.setEtat((byte) 1);
   } else if (e.getActionCommand().equals("Perso")) {
     this.etat = (byte) 2;
     this.indication.setEtat((byte) 2);
   } else if (e.getActionCommand().equals("Sortie")) {
     this.etat = (byte) 3;
     this.indication.setEtat((byte) 3);
   } else if (e.getActionCommand().equals("Sauvegarder")) {
     /* appel de la methode mapSaver */
     JFileChooser chooser = new JFileChooser("./MAP/");
     FileNameExtensionFilter filter = new FileNameExtensionFilter("Labyrinthe file (.lab)", "lab");
     chooser.setFileFilter(filter);
     int returnval = chooser.showOpenDialog(null);
     if (returnval == JFileChooser.APPROVE_OPTION) {
       System.out.println("You chose to save this file: " + chooser.getSelectedFile().getName());
       MapSaver map =
           new MapSaver(
               chooser.getSelectedFile(),
               (byte) this.maGrille.getTaille(),
               this.maGrille.getPosThesee(),
               this.maGrille.getPosSortie(),
               this.maGrille.getTabCases());
     } else {
       System.out.println("saving file aborded!");
     }
   } else if (e.getActionCommand().equals("Retour")) {
     /* retour au menu precedent */
     this.oldFenetre.setVisible(true);
     this.oldFenetre.repaint();
     this.maGrille.setClosed();
   }
   if (maGrille.estValide()) {
     this.sauvegarder.setEnabled(true);
   } else {
     this.sauvegarder.setEnabled(false);
   }
 }
Esempio n. 3
0
  public void actionPerformed(ActionEvent e) {
    String cmd = (e.getActionCommand());

    if (cmd.equals(aboutItem.getText()))
      JOptionPane.showMessageDialog(
          this,
          "Simple Image Program for DB2004\nversion 0.1\nThanks to BvS",
          "About imageLab",
          JOptionPane.INFORMATION_MESSAGE);
    else if (cmd.equals(quitItem.getText())) System.exit(0);
    else if (cmd.equals(openItem.getText())) {
      int returnVal = chooser.showOpenDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2 = new Picture(chooser.getSelectedFile().getName());
          pic1 = new Picture(pic2.width(), pic2.height());
          lab.setIcon(pic2.getJLabel().getIcon());
          sliderPanel.setVisible(false);
          pack();
          repaint();
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not open " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Open Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }

    } else if (cmd.equals(saveItem.getText())) {
      int returnVal = chooser.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2.save(chooser.getSelectedFile().getName());
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not write " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Save Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }
    }
  }