Foro de elhacker.net

Programación => Java => Mensaje iniciado por: yerson en 6 Junio 2009, 23:04 pm



Título: Como hacer un array de controles
Publicado por: yerson en 6 Junio 2009, 23:04 pm
Quisiera  hacer una matriz de botones :huh: .. estoy utilizando netbeans ... alguien me puede ayudar plz


Título: Re: Como hacer un array de controles
Publicado por: Nakp en 7 Junio 2009, 07:35 am
no es problema de saber utilizar una herramienta, es problema de lógica, conceptualización :silbar:

Código
  1. JButton botones[] = new JButton[40]; //tienes que iniciar CADA boton, ahi has declarado un "nuevo array de JButton"
  2.  
  3. //ahora hacemos que cada elemento del array sea un botón ;)
  4. for(int i=0; i<40; i++)
  5. botones[i] = new JButton();

salu2 :P


Título: Re: Como hacer un array de controles
Publicado por: yerson en 7 Junio 2009, 14:24 pm
Me referia al momento de diseñar

(http://img36.imageshack.us/img36/9454/dibujokfx.jpg) (http://img36.imageshack.us/my.php?image=dibujokfx.jpg)

o weno talvez no sepa onde poner ese codigo  :xD  voy a tratar de ubicarlo


Título: Re: Como hacer un array de controles
Publicado por: ~~ en 8 Junio 2009, 11:13 am
Citar
How Do I create an Array of GUI Controls in the NetBeans GUI Builder?

There is no IDE action dedicated to that. If the number of controls (the length of the array) is static, and you need the array only to loop over the controls, try this:

Add all components manually (via drag and drop). Then create an array in code and fill it with all the component variables.
http://wiki.netbeans.org/FaqGuiControlArray