• Post Reply Bookmark Topic Watch Topic
  • New Topic

Image and Image not the same....

 
Ko Wey
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the attention of the staff/customers of this excellent saloon:


I am doing some GUI-stuff(games for my old iMac/OS9+MrJ: thus obsolete). No Swing of course!

I want to create an image in memory (No class BufferedImage for this java-version). I thought about creating an image with

but this creates null as this(=some component) is not visible(yet), then I thought: I am going to be clever and do this:

Fine, and then I want to DO something with this image:

I get this stuff:
"java.lang.IllegalAccessError: getGraphics()
only valid for images created with createImage(w, h)"

Oh boy!
Any suggestions?
 
Ko Wey
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On topic of my question: the problem is that when, in the constructor, I do:

myComponent creates null so long it is not visible yet. So I can't call it in the constructor of myComponent, before setVisible(true);


So I can do this:



Another way around the problem is just placing the code for creating the image in a separate thread:

but that I find far from elegant! Oh well, anything better?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ko Wey
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is smart.
There is no call to paint() unless the component
is visible, I guess.
Thanks.
Mr. Wood for president!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!