Java - añuda con hilos

 
Vista:

añuda con hilos

Publicado por solete (5 intervenciones) el 17/10/2008 18:35:08
mira al compilar mi applet me da el siguete error:

Hola!!

Mira tu sabes porque salen estos errores??? yo creo que es que se ha exedido el hilo pero es que no se ni lo que coño significa eso??'

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at agujaBuffon.AppletPrincipal.actionPerformed(AppletPrincipal.java:371)
at javax.swing.AbstractButton.fireActionPerformed(Unknown 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.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(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(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown 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.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

creo que es cosa de los hilos, pero no llevo mucho con java y ya llevo dos dias y no se por donde atajarlo.

me sale eso al hacer click en un boton que sirve para lanzar lineas sobre un panel.

Bueno no se si me e explicado bien, pero agradecería ayuda porfavorrrrrrrrrrrrrrr
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:añuda con hilos

Publicado por Gilberto (378 intervenciones) el 18/10/2008 20:49:24
Es por algún objeto no instanciado en el método actionPerformed. Si publicas el código de este método podremos decite qué es lo que sucede.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:añuda con hilos

Publicado por solete (5 intervenciones) el 20/10/2008 08:39:44
(este codigo esta en la clase Applet principal)
public void actionPerformed(ActionEvent e){
Object source = e.getSource();
// si se pulsa el botón simular se muestra el applet
if(source==jbtnSimulacion)
jfrVentana.setVisible(true);



if ( source == jbtnUnoaUno)
{

int n_repetitions=1;
buffon.play(n_repetitions);
}




}

mira este es el codigo del actionPerformed para mas ayuda te envio tambien el del play lo que me da fallo pone puntero a null creo que tendra algo que ver con el vector o no se. porque si el codigo pley lo pongo en la misma clase donde esta el actionPerformed no me da problema, pero no se que puede ser. gracias de antemano

codigo play (este codigo esta en la clase BufffonControlPanel):

public void play( int repetitions) {
needleLength = 1.0;
floorWidth = floor.getAspectRatio()*floorHeight;
double centerX, centerY, xOff, yOff;
Vector<float[]> v = new Vector<float[]>();
float[] lineEnds;
for ( int i=0; i< repetitions; i++) {
lineEnds = new float[4];
plays++;
//center of needle is vertically distributed uniformly between
// 0.5 and floorHeight-0.5
centerY = 0.5+(floorHeight-1.0)*Math.random();

//center of needle is horizontally distributed uniformly between
// 0.5 and floorWidth-0.5
centerX= 0.5+(floorWidth-1.0)*Math.random();
//angle to upper end is uniformly distributed on [0, Pi]
theta = Math.PI*Math.random();
xOff = 0.5*needleLength*Math.sin(theta);
yOff = 0.5*needleLength*Math.cos(theta);
lineEnds[0] = (float)(centerX+xOff);
lineEnds[1] = (float)(centerY+yOff);
lineEnds[2] = (float)(centerX-xOff);
lineEnds[3] = (float)(centerY-yOff);
v.addElement(lineEnds);
if (Math.floor(lineEnds[1]) != Math.floor(lineEnds[3])) {
crossings++;
}

}
X = crossings/((double)plays);
if (X != 0){ r = 2/X;}
xField.setText(nf.format(X));
rcField.setText(nf.format(r));
floor.updateV(v);
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar