necesito ayuda con un error al compilar applet
Publicado por solete (5 intervenciones) el 20/10/2008 19:29:57
(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);
}
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 pregunta


0