Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/10/2014, 19:49
Olbapk
 
Fecha de Ingreso: octubre-2008
Mensajes: 184
Antigüedad: 15 años, 6 meses
Puntos: 1
no me deja modificar valor TextField

Hola a todos,
tengo una serie de TextField distribuidos por mi programa.
Para inicialiar los valores la primera vez, hago una funcion X, que me crea un array tipo TextField, y le añado los valores actuales de las cajas de texto (que están vacias". Comparo si los valores son iguales a la cadena de texto " " para comprobar si está vació, si lo está mete el valor que le paso por la función (esto es ya que deben estar en un orden concreto).

Pues bien, después de esto estoy intentando modificar los valores de las caja de texto, pero por alguna razón siempre me el mismo error.

La función para modicarlo es practicamente la misma

ArrayList<JTextField> a = new ArrayList <JTextField>();

a.add(a1);
a.add(a2);
a.add(a3);
a.add(a4);
a.add(a5);

a.get(0).setText("0");

aX son de tipo TextField.

Tengo aislado el error la función de edición de valores.He ido probando con diversas funciones (la idea era pasarle la posición donde debe modificar el valor, pero he llegado a esta expresión mas simplificada para poder comprobar que el acceso es correcto, pero siempre me da error. La llamada principal la hago en una clase, que llama a otra función de una clase diferente.

Aquí dejo el error:

java.lang.NullPointerException
at Factores.Atomizar(Factores.java:356)
at Factores.Dividir(Factores.java:253)
at Fisica.actionPerformed(Fisica.java:226)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


¡Gracias a todos por vuestro tiempo!