elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Java
| | | |-+  Ayuda algoritmo en java
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda algoritmo en java  (Leído 3,518 veces)
estherlui

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Ayuda algoritmo en java
« en: 27 Mayo 2012, 13:15 pm »

Hola buenas tardes a todos, necesito ayuda con este algoritmo en java, es el juego de la vida, tengo hecho esto, pero no se por donde seguir o que hacer mas, llevo más de una semana dándole vueltas y ya se me ha bloqueado hasta la mente, si alguien me pudiera ayudar le estaría muy agradecida.
Lo que tengo echo es lo siguiente:
------------------------------------------------------------------------------------------------------
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;


public class matriz extends JFrame {

private JButton[][] boton;
private int n;

/** Creates a new instance of Main */
   public matriz(int n) {
      this.n = n;
      boton = new JButton[n][n];
      this.setLayout(new GridLayout(n,n));
      for (int i = 0; i < n; i++) {
         for (int j = 0; j < n; j++) {
            boton[j] = new JButton();
            String nombre = new Integer(i).toString();
            nombre += new Integer(j).toString();
            boton[j].setActionCommand(nombre);
            this.add(boton[j]);
         }
      }
      this.addListeners();
      this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
      this.setSize(new Dimension(700,700));
   }
   public void addListeners() {
      for (int i = 0; i < n; i++) {
         for (int j = 0; j < n; j++) {
            boton[j].addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                  JButton evento = (JButton)evt.getSource();
                  System.out.println("apretado el boton "+evento.getActionCommand());
               }
            });
         }
      }
   }

   public static void main(String[] args) {
// TODO code application logic here

      matriz m = new matriz(7);
      m.setVisible(true);
      
   for (i = 0; i < n; i++)
   {
     for (j= 0; j < n; j++)
          {
       m = 0;
    if (boton[j] == celula < 2)
                 {
   boton.setBackground(Color.gray);
         
       }
       else if (botton[j] == celula > 3)
                 {
         boton.setBackground(Color.red);
       }
       else if (boton[j] == (celula == 2 || celula == 3))
                 {
         boton.setBackground(Color.red);
       }
       else if (boton[j] == celula == 3)
                 {
         boton.setBackground(Color.gray);
       }
          }
   }
}
   }


En línea

Proteus1989

Desconectado Desconectado

Mensajes: 184



Ver Perfil WWW
Re: Ayuda algoritmo en java
« Respuesta #1 en: 27 Mayo 2012, 23:05 pm »

Aquí tienes el código completo, busca lo que necesites.

http://casidiablo.net/juego-de-la-vida-java/


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Algoritmo en Java [SOLUCIONADO]
Java
Azulf 3 9,521 Último mensaje 21 Octubre 2007, 15:25 pm
por marioly
necesito por favor que me ayuden con el algoritmo en JAVA ECLIPSE indigo
Java
georgesf13 5 5,568 Último mensaje 2 Noviembre 2011, 05:00 am
por bengy
Ayuda algoritmo en java
Java
estherlui 0 1,647 Último mensaje 27 Mayo 2012, 13:13 pm
por estherlui
[PROBLEMA] Descifrado con algoritmo TripleDES en java
Java
kondrag_X1 0 2,220 Último mensaje 25 Abril 2013, 13:45 pm
por kondrag_X1
problema algoritmo java o dfd
Ejercicios
Kacoae 1 4,917 Último mensaje 19 Julio 2015, 03:12 am
por lvs
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines