Article View: borland.public.jbuilder.java.language
Article #17853Simple ??? double buffering
From: Rich Downing
Date: Fri, 11 Sep 1998 00:00
Date: Fri, 11 Sep 1998 00:00
70 lines
2347 bytes
2347 bytes
Alright folks,
I'm obviously missing something simple here. In the rather trivial
example that follows, the image is never shown on the screen. If I
comment out the offScreenGraphics.drawImage statement and uncomment
the offScreenGraphics.drawString statement the string will show
correctly.
I know that the url and images names are ok, because the image
displays correctly if I don't double buffer.
Any idea what is going on????
Thanks,
Rich
-------------------- code follows
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.net.*;
public class Omega extends Applet
{
String cam1 = "myimage.jpg";
Image cam1Image, offScreenImage;
Graphics offScreenGraphics;
public Omega()
{ }
public void init()
{ this.setSize(400,300); }
public void start()
{ repaint(); }
public void stop()
{ }
public void destroy()
{ offScreenGraphics.dispose(); }
public void paint(Graphics g)
{
if (cam1Image == null)
{
URL myurl = getDocumentBase();
offScreenImage = createImage(400, 300);
offScreenGraphics = offScreenImage.getGraphics();
cam1Image = getImage(myurl, cam1);
offScreenGraphics.drawImage(cam1Image, 0, 0, 400, 300, this);
// offScreenGraphics.drawString("A Test",30,30);
}
g.drawImage(offScreenImage, 0, 0, 400, 300, this);
}
public void update(Graphics g)
{ paint(g); }
}
----------------------------------------------------------------------
Richard V. Downing Home: http://rvd.home.mindspring.com
Senior Software Engineer Work: http://www.vsin.com
VideoConferencing Systems, Inc. Email: rvd@mindspring.com
Norcross, Ga
------------ When surrounded by wolves 'tis best to howl -------------
Technical Details
Message-ID:
<35f95363.10456418@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,13093a5f6f54aba2,start X-Google-Attributes: gidf74b3,public From: rvd@mindspring.com (Rich Downing) Subject: Simple ??? double buffering Date: 1998/09/11 Message-ID: <35f95363.10456418@forums.borland.com> X-Deja-AN: 390163388 Content-Transfer-Encoding: 7bit Organization: mindspring.com Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language