



public BotonAbrir(JLabel jotalabel)
{
super("Abrir",new ImageIcon(BotonAbrir.class.getResource("/images/openFile4.gif")));
this.jota = jotalabel;
this.putValue(ACCELERATOR_KEY,KeyStroke.getKeyStro ke(KeyEvent.VK_A, java.awt.Event.CTRL_MASK));
}
@Override
public void actionPerformed(ActionEvent e) //throws FileNotFoundException
{
valor=true;
if(this.hayImagen==true || BotonImportar.hayImagen==true)
{
javax.swing.JOptionPane.showMessageDialog(frame,"¡ Ya hay una imagen de fondo!","ADVERTENCIA",JOptionPane.WARNING_MESSAGE) ;
//setDefaultCloseOperation(javax.swing.WindowConstan ts.DO_NOTHING_ON_CLOSE);//le dice a java que no haga nada cuando se presione la X para cerrar la aplicaci�n
}
else
{
// jota.setIcon(null);
//creamos el dialogo
JFileChooser filechooser = new JFileChooser();
//lo configuramos con un filtro...
filechooser.addChoosableFileFilter(new ImageFilter());
// lo mostramos al usuario
int returnVal = filechooser.showOpenDialog(null);
// comprobamos lo que nos devuelve el usuario
try{
if (returnVal == JFileChooser.APPROVE_OPTION)
{ //el usuario selecciona un fichero
valor2=true;
foto=filechooser.getSelectedFile();
String ruta = filechooser.getSelectedFile().getPath();
jota.setIcon(new ImageIcon(ruta));
jota.repaint();
Ficheros ficheros=new Ficheros();
ficheros.setFoto(foto);
TablaModelo2 resumen=new TablaModelo2(foto,ruta);
//Aplicacion.getAplicacion().setModelo(modelo);
Aplicacion.getAplicacion().setTitle("ZONELLS 1.0 - Fondo: "+foto.getAbsolutePath());
hayImagen=true;
}//fin if
}//fin try
catch(Exception e2){//no pueden llamarse = que action event
throw new RuntimeException(e2);
}//fin catch
}
}//fin método
public BotonNuevo() {
super("Nuevo",new imageIcon(BotonNuevo.class.getResource("/images/nuevo1.gif")));
this.putValue(ACCELERATOR_KEY,KeyStroke.getKeyStro ke(KeyEvent.VK_N, java.awt.Event.CTRL_MASK));
}
@Override
public void actionPerformed(ActionEvent e) {
Aplicacion.getAplicacion().setTitle("ZONELLS 1.0");
if(BotonAbrir.hayImagen==true || BotonImportar.hayImagen==true)
{
if((BotonGuardar.getGuardado()==true)||(BotonGuard arComo.getGuardado()==true))
{
Aplicacion.getAplicacion().add(new Pizarra());
Aplicacion.getAplicacion().getSPane().setViewportV iew(new Pizarra());
BotonAbrir.setImagen(false);
BotonImportar.setImagen(false);
//jota.setIcon(null);
}
else
{
JFrame frame=new JFrame();
opcion=JOptionPane.showConfirmDialog(frame,"No ha guardado los cambios.¿Seguro que quieres abrir un nuevo modelo?Los cambios se perderán","IMPORTANTE",JOptionPane.YES_NO_OPTION);
if(opcion==JOptionPane.YES_OPTION)
Aplicacion.getAplicacion().add(new Pizarra());
Aplicacion.getAplicacion().getSPane().setViewportV iew(new Pizarra());
BotonAbrir.setImagen(false);
BotonImportar.setImagen(false);
// jota.setIcon(null);
}
}
}
Cualquier aportación me vale.Gracias