package UhuRisk;


import java.awt.Component;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.Observable;

/*
 * fatacar.java
 *
 * Created on 15 de enero de 2009, 10:42
 */
import java.util.Observer;
import javax.swing.JOptionPane;



/**
 *
 * @author  juan antonio
 */
public class fatacar extends javax.swing.JFrame implements Observer{

    MP3 mp3 = new MP3("/BSO Piratas del Caribe - He'S A Pirate.mp3");
    
    private Territorio terAtacante;
    
    private Territorio terDefensor;
    
    private Partida miPartida;
    
    private fTablero tablero;

    
    private Dado dadoAtaque;
    
    private Dado dadoDefensa;
    
    private ArrayList<javax.swing.JLabel> ldadosat;
    
    private ArrayList<javax.swing.JLabel> ldadosdef;
    
    private ArrayList<javax.swing.ImageIcon> ldibat;
    
    private ArrayList<javax.swing.ImageIcon> ldibdef;
    
    /** Creates new form fatacar */
    public fatacar(Territorio ta, Territorio td, Partida p, fTablero ft) {
        initComponents();
        this.mp3.play();
        dadoAtaque=new Dado("Ataque");
        dadoDefensa=new Dado("Defensa");
        ldadosat=new ArrayList(3);
        ldadosdef=new ArrayList(2);
        terAtacante=ta;
        terDefensor=td;
        miPartida=p;
        tablero=ft;
        bcontinuar.setVisible(false);
        linformacion.setVisible(false);
        ltirat.setVisible(false);
        ltirdef.setVisible(false);
        bsalir.setVisible(false);
        snumEjercitos.setVisible(false);
        lnumEjercitos.setVisible(false);
        binvadir.setVisible(false);
        ldadosat.add(ldadoat1);
        ldadosat.add(ldadoat2);
        ldadosat.add(ldadoat3);
        ldadoat1.setVisible(false);
        ldadoat2.setVisible(false);
        ldadoat3.setVisible(false);
        ldadosdef.add(ldadodef1);
        ldadosdef.add(ldadodef2);
        ldadodef1.setVisible(false);
        ldadodef2.setVisible(false);
        linfoat.setText(terAtacante.getNomTerritorio()+" ("+terAtacante.getNumEjercitos()+" ejercitos)");
        linfodef.setText(terDefensor.getNomTerritorio()+" ("+terDefensor.getNumEjercitos()+"ejercitos)");
        linfoat.setBackground(terAtacante.getColor());
        linfodef.setBackground(terDefensor.getColor());
        ldibat=new ArrayList();
        ldibdef=new ArrayList();
        ldibat.add(new javax.swing.ImageIcon(getClass().getResource("/dado1.GIF")));
        ldibat.add(new javax.swing.ImageIcon(getClass().getResource("/dado2.GIF")));
        ldibat.add(new javax.swing.ImageIcon(getClass().getResource("/dado3.GIF")));
        ldibat.add(new javax.swing.ImageIcon(getClass().getResource("/dado4.GIF")));
        ldibat.add(new javax.swing.ImageIcon(getClass().getResource("/dado5.GIF")));
        ldibat.add(new javax.swing.ImageIcon(getClass().getResource("/dado6.GIF")));
        ldibdef.add(new javax.swing.ImageIcon(getClass().getResource("/dado1a.GIF")));
        ldibdef.add(new javax.swing.ImageIcon(getClass().getResource("/dado2a.GIF")));
        ldibdef.add(new javax.swing.ImageIcon(getClass().getResource("/dado3a.GIF")));
        ldibdef.add(new javax.swing.ImageIcon(getClass().getResource("/dado4a.GIF")));
        ldibdef.add(new javax.swing.ImageIcon(getClass().getResource("/dado5a.GIF")));
        ldibdef.add(new javax.swing.ImageIcon(getClass().getResource("/dado6a.GIF")));
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ldadoat2 = new javax.swing.JLabel();
        ldadoat3 = new javax.swing.JLabel();
        ldadodef2 = new javax.swing.JLabel();
        ldadodef1 = new javax.swing.JLabel();
        ldadoat1 = new javax.swing.JLabel();
        lterat = new javax.swing.JLabel();
        lterdef = new javax.swing.JLabel();
        linfoat = new javax.swing.JLabel();
        linfodef = new javax.swing.JLabel();
        ltirat = new javax.swing.JLabel();
        ltirdef = new javax.swing.JLabel();
        linformacion = new javax.swing.JLabel();
        batacar = new javax.swing.JButton();
        bterminar = new javax.swing.JButton();
        bsalir = new javax.swing.JButton();
        lnumEjercitos = new javax.swing.JLabel();
        snumEjercitos = new javax.swing.JSlider();
        binvadir = new javax.swing.JButton();
        bcontinuar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setAlwaysOnTop(true);

        ldadoat2.setBackground(new java.awt.Color(255, 255, 255));
        ldadoat2.setFont(new java.awt.Font("Tahoma", 1, 18));
        ldadoat2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ldadoat2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true));
        ldadoat2.setOpaque(true);

        ldadoat3.setBackground(new java.awt.Color(255, 255, 255));
        ldadoat3.setFont(new java.awt.Font("Tahoma", 1, 18));
        ldadoat3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ldadoat3.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true));
        ldadoat3.setOpaque(true);

        ldadodef2.setBackground(new java.awt.Color(255, 255, 255));
        ldadodef2.setFont(new java.awt.Font("Tahoma", 1, 18));
        ldadodef2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ldadodef2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true));
        ldadodef2.setOpaque(true);

        ldadodef1.setBackground(new java.awt.Color(255, 255, 255));
        ldadodef1.setFont(new java.awt.Font("Tahoma", 1, 18));
        ldadodef1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ldadodef1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true));
        ldadodef1.setOpaque(true);

        ldadoat1.setBackground(new java.awt.Color(255, 255, 255));
        ldadoat1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        ldadoat1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ldadoat1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true));
        ldadoat1.setOpaque(true);

        lterat.setFont(new java.awt.Font("Tahoma", 1, 12));
        lterat.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lterat.setText("Territorio atacante");
        lterat.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2));

        lterdef.setFont(new java.awt.Font("Tahoma", 1, 12));
        lterdef.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lterdef.setText("Territorio atacado");
        lterdef.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2));

        linfoat.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        linfoat.setText("jLabel3");
        linfoat.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        linfoat.setOpaque(true);

        linfodef.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        linfodef.setText("jLabel4");
        linfodef.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        linfodef.setOpaque(true);

        ltirat.setFont(new java.awt.Font("Tahoma", 1, 12));
        ltirat.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ltirat.setText("Tirada de ataque");
        ltirat.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2));

        ltirdef.setFont(new java.awt.Font("Tahoma", 1, 12));
        ltirdef.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ltirdef.setText("Tirada de defensa");
        ltirdef.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2));

        linformacion.setBackground(java.awt.Color.white);
        linformacion.setFont(new java.awt.Font("Tahoma", 1, 14));
        linformacion.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        linformacion.setText("jLabel12");
        linformacion.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 3));
        linformacion.setOpaque(true);

        batacar.setText("Atacar");
        batacar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                batacarActionPerformed(evt);
            }
        });

        bterminar.setText("Terminar ataque");
        bterminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bterminarActionPerformed(evt);
            }
        });

        bsalir.setText("Salir");
        bsalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bsalirActionPerformed(evt);
            }
        });

        lnumEjercitos.setText("Numero de ejercitos para invadir el territoio conquistado:");

        snumEjercitos.setMajorTickSpacing(1);
        snumEjercitos.setMaximum(6);
        snumEjercitos.setMinimum(2);
        snumEjercitos.setMinorTickSpacing(1);
        snumEjercitos.setPaintLabels(true);
        snumEjercitos.setPaintTicks(true);
        snumEjercitos.setSnapToTicks(true);
        snumEjercitos.setValue(2);

        binvadir.setText("Invadir");
        binvadir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                binvadirActionPerformed(evt);
            }
        });

        bcontinuar.setText("Continuar");
        bcontinuar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bcontinuarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(105, 105, 105)
                        .addComponent(batacar, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(52, 52, 52)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(bterminar)
                                .addGap(56, 56, 56)
                                .addComponent(bcontinuar, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(binvadir))
                            .addComponent(bsalir, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(43, 43, 43)
                        .addComponent(ltirat, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(207, 207, 207)
                        .addComponent(ltirdef, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(94, 94, 94)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ldadoat1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ldadoat2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ldadoat3, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(316, 316, 316)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(ldadodef1, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
                            .addComponent(ldadodef2, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(linfoat, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(142, 142, 142)
                        .addComponent(linfodef, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(56, 56, 56)
                        .addComponent(lterat, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(222, 222, 222)
                        .addComponent(lterdef, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(linformacion, javax.swing.GroupLayout.PREFERRED_SIZE, 706, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addComponent(lnumEjercitos)
                        .addGap(33, 33, 33)
                        .addComponent(snumEjercitos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(56, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lterat)
                    .addComponent(lterdef))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(linfoat)
                    .addComponent(linfodef))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ltirat)
                    .addComponent(ltirdef))
                .addGap(7, 7, 7)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ldadoat1, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(9, 9, 9)
                        .addComponent(ldadoat2, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(ldadoat3, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ldadodef1, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(ldadodef2, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(53, 53, 53)
                .addComponent(linformacion)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(batacar)
                    .addComponent(bterminar)
                    .addComponent(bcontinuar))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(39, 39, 39)
                        .addComponent(lnumEjercitos))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(snumEjercitos, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(30, 30, 30)
                .addComponent(bsalir)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(binvadir)
                .addContainerGap(35, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents



private void batacarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_batacarActionPerformed
// TODO add your handling code here:
    if(this.terAtacante.getNumEjercitos()>1){
        this.dadoAtaque.addObserver(this);
        this.dadoDefensa.addObserver(this);
        String mensaje=miPartida.getJugador(miPartida.getJugadorActivo()).atacarTerritorio(terAtacante, terDefensor, dadoAtaque, dadoDefensa);
        linformacion.setText(mensaje);
        linformacion.setVisible(true);
        linfoat.setText(terAtacante.getNomTerritorio()+" ("+terAtacante.getNumEjercitos()+" ejercitos)");
        linfodef.setText(terDefensor.getNomTerritorio()+" ("+terDefensor.getNumEjercitos()+"ejercitos)");
        linfoat.setVisible(true);
        linfodef.setVisible(true);
        ltirat.setVisible(true);
        ltirdef.setVisible(true);
        if(this.terDefensor.getNumEjercitos()==0){
            batacar.setVisible(false);
            bterminar.setVisible(false);
            bcontinuar.setVisible(true);
            linformacion.setText("Se ha conquistado "+this.terDefensor.getNomTerritorio()+". Pulse continuar.");
            linfodef.setBackground(miPartida.getJugador(miPartida.getJugadorActivo()).getColor());
        }
    }
    else{
        linformacion.setText("El territorio "+this.terAtacante.getNomTerritorio()+" no tiene suficientes ejercitos para atacar.");
        batacar.setVisible(false);
    }
}//GEN-LAST:event_batacarActionPerformed

private void bterminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bterminarActionPerformed
// TODO add your handling code here:
    tablero.setEnabled(true);
    tablero.setTerDefensor(null);
    tablero.setTerAtacante(null);
    this.dispose();
}//GEN-LAST:event_bterminarActionPerformed

private void binvadirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_binvadirActionPerformed
// TODO add your handling code here:
    miPartida.getJugador(miPartida.getJugadorActivo()).invadirTerritorio(terAtacante, terDefensor, snumEjercitos.getValue());
    linfoat.setText(terAtacante.getNomTerritorio()+" ("+terAtacante.getNumEjercitos()+" ejercitos)");
    linfodef.setText(terDefensor.getNomTerritorio()+" ("+terDefensor.getNumEjercitos()+"ejercitos)");
    linformacion.setText("Se ha invadido "+terDefensor.getNomTerritorio()+"con "+snumEjercitos.getValue()+" ejercitos.");
    binvadir.setVisible(false);
    bsalir.setVisible(true);
}//GEN-LAST:event_binvadirActionPerformed

private void bsalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bsalirActionPerformed
// TODO add your handling code here:
    tablero.setEnabled(true);
    tablero.setTerDefensor(null);
    tablero.setTerAtacante(null);
    this.mp3.close();
    this.dispose();
    tablero.mp3.play();
}//GEN-LAST:event_bsalirActionPerformed

private void bcontinuarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bcontinuarActionPerformed
// TODO add your handling code here:
    linformacion.setText("Seleccione un numero de ejercitos para invadir el territorio conquistado.");
    ltirat.setVisible(false);
    ltirdef.setVisible(false);
    int num=ldadosat.size();
    int i;
    for(i=0; i<num; i++){
        ldadosat.get(i).setVisible(false);
    }
    num=ldadosdef.size();
    for(i=0; i<num; i++){
        ldadosdef.get(i).setVisible(false);
    }
    snumEjercitos.setMinimum(1);
    snumEjercitos.setMaximum(this.terAtacante.getNumEjercitos()-1);
    lnumEjercitos.setVisible(true);
    snumEjercitos.setVisible(true);
    bcontinuar.setVisible(false);
    binvadir.setVisible(true);
}//GEN-LAST:event_bcontinuarActionPerformed

    /**
    * @param args the command line arguments
    */
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton batacar;
    private javax.swing.JButton bcontinuar;
    private javax.swing.JButton binvadir;
    private javax.swing.JButton bsalir;
    private javax.swing.JButton bterminar;
    private javax.swing.JLabel ldadoat1;
    private javax.swing.JLabel ldadoat2;
    private javax.swing.JLabel ldadoat3;
    private javax.swing.JLabel ldadodef1;
    private javax.swing.JLabel ldadodef2;
    private javax.swing.JLabel linfoat;
    private javax.swing.JLabel linfodef;
    private javax.swing.JLabel linformacion;
    private javax.swing.JLabel lnumEjercitos;
    private javax.swing.JLabel lterat;
    private javax.swing.JLabel lterdef;
    private javax.swing.JLabel ltirat;
    private javax.swing.JLabel ltirdef;
    private javax.swing.JSlider snumEjercitos;
    // End of variables declaration//GEN-END:variables

    public void update(Observable o, Object arg) {
        Dado d=(Dado)o;
        int[] aux=d.getTirada();
        int num=aux.length;
        int i;
        if(d.getTipo().compareTo("Ataque")==0){
            for(i=0;i<num;i++){
               ldadosat.get(i).setVisible(true);
               String path="/dado"+aux[i]+".GIF";
               ldadosat.get(i).setIcon(new javax.swing.ImageIcon(getClass().getResource(path)));
               int h=ldadosat.get(i).getIcon().getIconHeight();
               int w=ldadosat.get(i).getIcon().getIconWidth();
               ldadosat.get(i).setSize(w, h);
            }
        }
        else{
            for(i=0;i<num;i++){
               ldadosdef.get(i).setVisible(true);
               String path="/dado"+aux[i]+"a.GIF";
               ldadosdef.get(i).setIcon(new javax.swing.ImageIcon(getClass().getResource(path)));
               int h=ldadosdef.get(i).getIcon().getIconHeight();
               int w=ldadosdef.get(i).getIcon().getIconWidth();
               ldadosdef.get(i).setSize(w, h);
            }
        }
    }
}
