Presentacion
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
import portaretrato.Lista;
public class Avance extendsAbstractAction{
public static final int SIGUIENTE = 1;
public static final int ANTERIOR = 2;
Lista archivos;
Display pantalla;
Foto jpFoto;
public Avance(Lista archivos,Display pantalla) {
this.archivos = archivos;
this.pantalla = pantalla;
jpFoto=new Foto();
}
public void actionPerformed(ActionEvent e) {
Integerdireccion= Integer.parseInt(((Component)e.getSource()).getName());
if(direccion==null)return;
File actual = null;
switch(direccion){
case Avance.SIGUIENTE:actual=archivos.getSiguiente();
break;
case Avance.ANTERIOR:
actual=archivos.getAnterior();
break;
default:throw new UnsupportedOperationException("Método no permitido.");
}
BufferedImage bi = null;
try {
bi = ImageIO.read(actual);
} catch(IOException ex) {
Logger.getLogger(Avance.class.getName()).log(Level.SEVERE, null, ex);
}
this.jpFoto.setfotoActual(bi);
pantalla.remove(jpFoto);pantalla.add(jpFoto, BorderLayout.CENTER);
jpFoto.updateUI();
pantalla.publicarNombreArchivo(actual.getName());
}
}
package gui;
import java.awt.Graphics;
import java.awt.Image;import java.awt.image.BufferedImage;
/**
*/
public class Foto extends javax.swing.JPanel {
private Image fotoActual;
//CONSTRUCTOR
/** Creates new form Foto */
protected...
Regístrate para leer el documento completo.