• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

double buffering in applications

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello eveybody
I have done double buffering in applets but i want to use the technique in an application. When i call getGraphics() on the image it creates a nullPointerException, despite having used createImage(width, height) to create an offscreen image. Is it possible to use this method in an application, if so how?
thanks
 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getGraphics() is a method of Component, not Image. You normally call it on the Frame/Canvas or whatever youre working on.
Double buffering should work the same in an application as it does in an applet, as far as I know.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ed,
Where are you calling getGraphics() and createImage()? You have to do these when the component you are getting them from is already displayed (i.e. has a Graphics object associated with it)... You get a NullPointerException is you do these in the wrong place.
HTH,
-Nate
 
reply
    Bookmark Topic Watch Topic
  • New Topic