public void actionPerformed(ActionEvent e) {
   if (cChooser == null) {
     cChooser = new JColorChooser();
   }
   Color color =
       cChooser.showDialog(
           target, "Available Colors", ((ColoredIcon) target.getIcon()).getCurrentColor());
   target.setIcon(new ColoredIcon(color));
   target.doClick();
 }
示例#2
0
  public void actionPerformed(ActionEvent event) {

    if (posicion == -2) posicion = indexaux;

    // Abrir nueva imagen
    if (event.getSource() == carpeta) {

      siguiente.setEnabled(true);
      atras.setEnabled(true);
      presentacion.setEnabled(true);
      grid.setEnabled(true);
      bcomentario.setEnabled(true);
      zoom.setEnabled(true);

      imagenesbean.clear();

      if (imagenes != null) {
        imagenes.clear();
      }

      returnChooser = chooser.showOpenDialog(ArcViewer.this);
      imagenes = lista.Miranda(chooser, returnChooser);

      for (int asd1 = 0; asd1 < imagenes.size(); asd1++) {
        imagenesbean.add(new ImagenBean(imagenes.get(asd1), 0, 0));
      }

      String getImgSelected = chooser.getSelectedFile().getPath();

      for (int index = 0; index < imagenesbean.size(); index++) {
        if (getImgSelected.equals(imagenesbean.get(index).getIcon())) {
          imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon()));
          indexaux = index;
        }
      }
    }

    // Imagen siguiente
    if (event.getSource() == siguiente) {
      posicion++;
      if (posicion >= imagenesbean.size()) {
        posicion = 0;
      }

      imagen.setIcon(
          ajustar.ajusteImg(
              new ImageIcon(imagenesbean.get(posicion).getIcon()),
              imagenesbean.get(posicion).getAncho(),
              imagenesbean.get(posicion).getAlto(),
              areaventana.getWidth() - 50,
              areaventana.getHeight()));
    }

    // Imagen anterior
    if (event.getSource() == atras) {
      posicion--;
      if (posicion == -1) {
        posicion = imagenesbean.size() - 1;
      }

      imagen.setIcon(
          ajustar.ajusteImg(
              new ImageIcon(imagenesbean.get(posicion).getIcon()),
              imagenesbean.get(posicion).getAncho(),
              imagenesbean.get(posicion).getAlto(),
              areaventana.getWidth() - 50,
              areaventana.getHeight()));
    }

    // Presentacion iniciar/detener
    if (event.getSource() == presentacion) {

      if (isPresentacion == false) {
        grid.setVisible(false);
        atras.setVisible(false);
        siguiente.setVisible(false);
        carpeta.setVisible(false);
        bcomentario.setVisible(false);
        zoom.setVisible(false);
        ptiempo.setVisible(true);
      }

      if (isPresentacion == true) {
        grid.setVisible(true);
        atras.setVisible(true);
        siguiente.setVisible(true);
        carpeta.setVisible(true);
        bcomentario.setVisible(true);
        zoom.setVisible(true);
        ptiempo.setVisible(false);
      }

      if (presentacion.getIcon() == imgPausa) {
        slide.detener();
        posicion = slide.getPosicion();
        presentacion.setIcon(imgPlay);
        isPresentacion = false;
        return;
      }

      if (presentacion.getIcon() == imgPlay) {
        slide.setTodo(posicion, imagen, imagenesbean, areaventana, ptiempo);
        new Thread(slide, "prueba").start();
        presentacion.setIcon(imgPausa);
        isPresentacion = true;
        return;
      }
    }

    // Modo rejilla
    if (event.getSource() == grid) {

      imagen.setVisible(false);
      siguiente.setVisible(false);
      atras.setVisible(false);
      presentacion.setVisible(false);
      grid.setVisible(false);
      bcomentario.setVisible(false);
      zoom.setVisible(false);
      carpeta.setVisible(false);
      ptiempo.setVisible(false);

      // desplazamiento.setVisible(true);

      if (corrobora == true) {
        for (int celular = 0; celular < imgButtonArray.length; celular++) {
          imgButtonArray[celular].setVisible(true);
        }
      }

      if (corrobora == false) {
        imgButtonArray = new JButton[imagenesbean.size()];

        for (int goku = 0; goku < imagenesbean.size(); goku++) {
          areaventana.add(imgButtonArray[goku] = new JButton());
          imgButtonArray[goku].setPreferredSize(new Dimension(200, 200));
          imgButtonArray[goku].addActionListener(this);
          imgButtonArray[goku].setBackground(colorGris);
          imgButtonArray[goku].setIcon(
              ajustar.ajusteCuadrado(new ImageIcon(imagenesbean.get(goku).getIcon())));
          corrobora = true;
        }
      }
    }

    // Comentario
    if (event.getSource() == bcomentario) {
      new Comentario(imagenesbean.get(posicion), posicion);
    }

    // Cuando se apreta un boton de la rejilla
    if (corrobora == true) {
      for (int alice = 0; alice < imgButtonArray.length; alice++) {
        if (event.getSource() == imgButtonArray[alice]) {
          for (int wonderland = 0; wonderland < imgButtonArray.length; wonderland++) {
            imgButtonArray[wonderland].setVisible(false);
          }
          posicion = alice;

          imagen.setIcon(
              ajustar.ajusteImg(
                  new ImageIcon(imagenesbean.get(posicion).getIcon()),
                  imagenesbean.get(posicion).getAncho(),
                  imagenesbean.get(posicion).getAlto(),
                  areaventana.getWidth() - 50,
                  areaventana.getHeight()));

          imagen.setVisible(true);
          siguiente.setVisible(true);
          atras.setVisible(true);
          presentacion.setVisible(true);
          grid.setVisible(true);
          bcomentario.setVisible(true);
          zoom.setVisible(true);
          carpeta.setVisible(true);
        }
      }
    }

    if (event.getSource() == zoom) {
      System.out.println("Haciendo un ZOOOOOOOOOOOOM");
    }
  }
 ColorChooserAction(JButton target) {
   super(null, target.getIcon());
   this.target = target;
 }