Ayuda getGraphics()
Publicado por Noelia (2 intervenciones) el 18/02/2009 20:54:41
Hola, tengo un problema con el siguiente codigo:
public class PruebaNube extends JPanel{
int numImagenes = 3;
Imagen imagenes[];
Image buffer;
Graphics pantallaVirtual;
public PruebaNube(){
this.setBackground(new Color(255,255,255));
if(buffer == null){
buffer = createImage(this.getWidth(), this.getHeight());
}
pantallaVirtual = buffer.getGraphics();
}
}
Este codigo realmente no tiene funcionalidad, pero simplemente con esto ya me salta la Excepcion NullPointerExcepcion. El problema es que ---buffer = createImage(this.getWidth(), this.getHeight())--- me devuelve null; y por lo tanto al hacer ---pantallaVirtual = buffer.getGraphics();- salta dicha excepcion.
He buscado por todos lados pero no doy con la solucion, por favor espero su ayuda.
Muchas gracias
Un saludo.
public class PruebaNube extends JPanel{
int numImagenes = 3;
Imagen imagenes[];
Image buffer;
Graphics pantallaVirtual;
public PruebaNube(){
this.setBackground(new Color(255,255,255));
if(buffer == null){
buffer = createImage(this.getWidth(), this.getHeight());
}
pantallaVirtual = buffer.getGraphics();
}
}
Este codigo realmente no tiene funcionalidad, pero simplemente con esto ya me salta la Excepcion NullPointerExcepcion. El problema es que ---buffer = createImage(this.getWidth(), this.getHeight())--- me devuelve null; y por lo tanto al hacer ---pantallaVirtual = buffer.getGraphics();- salta dicha excepcion.
He buscado por todos lados pero no doy con la solucion, por favor espero su ayuda.
Muchas gracias
Un saludo.
Valora esta pregunta


0