Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/01/2012, 11:30
caverdugo
 
Fecha de Ingreso: enero-2012
Mensajes: 4
Antigüedad: 12 años, 3 meses
Puntos: 0
Pregunta Respuesta: ActionListener

acá dejo el código que tengo..


este es mi JPanel "Celda"
Código Javascript:
Ver original
  1. package thegameoflife;
  2.  
  3.  
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6.  
  7.  
  8.  
  9. public class Celda extends javax.swing.JPanel implements ActionListener {
  10.  
  11.  
  12.  
  13.     public Celda() {
  14.  
  15.         initComponents();
  16.         this.setOpaque(false);
  17.      
  18.      
  19.        
  20.         }
  21.  
  22.     @SuppressWarnings("unchecked")
  23.    
  24.  
  25.     public void actionPerformed(ActionEvent arg0) {
  26.        
  27.       acá no se que iría.. .
  28.        
  29.     }


y este es el JPanel "Matriz" que implementa Celda
Código Javascript:
Ver original
  1. package thegameoflife;
  2.  
  3.  
  4. import java.util.ArrayList;
  5. import javax.swing.ImageIcon;
  6.  
  7.  
  8. public class Matriz extends javax.swing.JFrame {
  9.  
  10.      
  11.     int rows;
  12.     int columns;
  13.     int nrOfCells;
  14.     ArrayList<Celda> cells = new ArrayList<Celda>();
  15.  
  16.  
  17.     public Matriz(String size) {
  18.         initComponents();
  19.         rows = Integer.parseInt(size);
  20.         columns = Integer.parseInt(size);
  21.         System.out.println(rows+" "+columns);
  22.         mainPanel.setLayout(new java.awt.GridLayout(rows,columns,2,2));
  23.         nrOfCells = rows*columns;
  24.         for(int i=0; i<nrOfCells;i++){
  25.             cells.add(new Celda());
  26.             mainPanel.add(cells.get(cells.size()-1));
  27.         }
  28.         Imagen panel = new Imagen(new ImageIcon("images/UnderTheSea.jpg").getImage());
  29.         this.getContentPane().add(panel);
  30.         this.pack();
  31.         mainPanel.setOpaque(false);
  32.         menuPanel.setOpaque(false);
  33.     }
  34.  
  35.   @SuppressWarnings("unchecked")
  36.  
  37.   public static void main(String args[]) {
  38.  
  39.         try {
  40.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  41.                 if ("Nimbus".equals(info.getName())) {
  42.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  43.                     break;
  44.                 }
  45.             }
  46.         } catch (ClassNotFoundException ex) {
  47.             java.util.logging.Logger.getLogger(Matriz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  48.         } catch (InstantiationException ex) {
  49.             java.util.logging.Logger.getLogger(Matriz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  50.         } catch (IllegalAccessException ex) {
  51.             java.util.logging.Logger.getLogger(Matriz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  52.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  53.             java.util.logging.Logger.getLogger(Matriz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  54.         }
  55.         Main.matriz = new Matriz(args[0]);
  56.         Main.matriz.setVisible(true);
  57.  
  58.     }
  59.        
  60.    
  61.  
  62.     // Variables declaration - do not modify
  63.     private javax.swing.JButton AddPlankton;
  64.     private javax.swing.JButton AddSardines;
  65.     private javax.swing.JButton AddSeaUrchins;
  66.     private javax.swing.JButton AddSharks;
  67.     private javax.swing.JButton Start;
  68.     private javax.swing.JButton Stop;
  69.     private javax.swing.JPanel mainPanel;
  70.     private javax.swing.JPanel menuPanel;