• Advertisement

Archived

This topic is now archived and is closed to further replies.

[java] Transparent canvas, background images?

This topic is 5265 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In order to avoid flashing while drawing, I came up with an idea, but I don''t know if it is possible to do in Java... With any sort of Java API, could I place one canvas on the "bottom," underneath anything, not changing until it is told to change. On top of that, would go a transparent canvas, except for the areas where the characters are drawn. Is this possible?

Share this post


Link to post
Share on other sites
Advertisement
Why don''t you just use the standard methods of getting rid of flashing? All you have to do is overload one function.

The Artist Formerly Known as CmndrM

http://chaos.webhop.org

Share this post


Link to post
Share on other sites
First, don''t use Canvas, use Panel.

Second, to avoid flashing, you use a backbuffer. Create a blank Image, do all your drawing to that Image, then draw that Image to the Panel. You also have to overridge the update() method like this:

public void update(Graphics g) {
paint(g);
}




First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites
OMG, that worked REALLY well. The course I took as an "Intro to Java" had a phrase that went:


Override paint, call repaint, and don''t mess with update.


Guess there are some situations where abovePhrase == false;

Share this post


Link to post
Share on other sites
What they mean is don''t call update directly. You always call repaint.



First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites

  • Advertisement