Article View: borland.public.jbuilder.java.api
Article #2595Applet Flicker, how to prevent? // Canvas, how to draw inage on?
From: Dave Bird
Date: Fri, 22 Sep 2000 00:00
Date: Fri, 22 Sep 2000 00:00
57 lines
2550 bytes
2550 bytes
Hi. On my homepage http://www.semu.demon.co.uk/index.html you will see
a couple of applets with links to the source files,a circular clockface
(old) and an animated ascii trotting-dog (new, needs swing to view).
They flicker something rotten; yet I have seen what are apparently
java applets on other pages that flow smoothly.
Can anyone explain simply how to cure this? Apparently I would need
to have one bitmap showing on the screen, and another bitmap which
I can have fully rendered then make visible i.e. blatt into the
screen image, But I don't know how to do this.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Also, I want to have a component (Canvas? TransparentImage?) on which
I can draw a GIF file then draw lines, ellipses, text etcetera upon
the image; also possibly give it a listener to pick up mouse clicks
and print some info about the region clicked over. Sounds
straightforward enough, but......... How do I do this?
I now how to put a GIF on a Button, because there is an
actual subclass ImageIcon extending the abstract class Image,
and I can use one of those. What subclass of image do I use
to put on a Canvas? what implementation of ImageObserver??
(and is there any more info on this?).
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
public class MyCanv2 extends Canvas {
//ImageObserver obs = new ImageObserver();
//Image img = new Image("c:\\ukco\\demon\\xemu\\icons\\globe4.gif");
/*
/ ..................construct
*/
public MyCanv2() { ; }
/*
/ .......................draw
*/
public void draw(Graphics g){
//g.drawImage(img,2,2,obs);
g.drawLine ( 2, 2,80,80);
}
}
// Won't compile if those lines are de-commented.
--
^-^-^-@@-^-;-^ http://www.xemu.demon.co.uk/
(..)__u news:alt.smoking.mooses
Technical Details
Message-ID:
<DaryTTDFW9y5EwcW@xemu.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,48a02984c2598a07,start X-Google-Attributes: gid1089d0,public From: Dave Bird <dave@xemu.demon.co.uk> Subject: Applet Flicker, how to prevent? // Canvas, how to draw inage on? Date: 2000/09/22 Message-ID: <DaryTTDFW9y5EwcW@xemu.demon.co.uk> X-Deja-AN: 673023888 X-NNTP-Posting-Host: xemu.demon.co.uk:158.152.196.209 X-Trace: news.demon.co.uk 969659839 nnrp-12:29917 NO-IDENT xemu.demon.co.uk:158.152.196.209 Organization: none MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.api X-Complaints-To: abuse@demon.net