[java] Transparent canvas, background images?

Started by
3 comments, last by TreizeSG 20 years, 7 months ago
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?
Project ARPEG: Product, Darkness SeigeThe seige begins...
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
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
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
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;
Project ARPEG: Product, Darkness SeigeThe seige begins...
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
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]

This topic is closed to new replies.

Advertisement