Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/10/2005, 14:53
cybergatita
 
Fecha de Ingreso: octubre-2005
Mensajes: 17
Antigüedad: 18 años, 7 meses
Puntos: 0
array bidimensional

hola chicos, me podrian asesorar con mi codigo
se trata que mediante un textfield llenar un arreglo bidimensional y cuando este llene que se sumen entre los elementos.
de antemano gracias chicos

public class bidi extends Applet implements ActionListener
{
private int arr[][]=new int [5][2];
private TextField cuadro;
private Button boto;
private int x,y,k;
private int aux=0;

public void init(){
cuadro=new TextField (2);
add(cuadro);
boto=new Button ("GUARDA VALOR");
add(boto);
boto.addActionListener(this);
}
public void paint(Graphics g){

for(x=0; x<5; x++){
for(y=0; y<2; y++){
aux=aux +arr[x][y];
}
}

g.drawString(""+ aux,100,50);

}
public void actionPerformed(ActionEvent e){
arr[k][k]=Integer.parseInt(cuadro.getText());
k++;
repaint ();

}

}