Article View: borland.public.jbuilder.java.language
Article #8326Re: DESPERATE !!!
From: Joi Ellis [TeamB]
Date: Fri, 30 Mar 2001 18:21
Date: Fri, 30 Mar 2001 18:21
58 lines
2740 bytes
2740 bytes
Carlos Ojea Castro <ccastro@rslcom.es> wrote:
> Thank you very much Joi. The exact code is :
> import java.applet.Applet;
> import java.awt.*;
> public class Pintar extends Applet
> {
> Image TableroImg, TableroGif;
> Graphics Tablero_Buffer;
> boolean TD;
> public void init()
> {
> TD = true;
> TableroImg = createImage (328,423);
> Tablero_Buffer = TableroImg.getGraphics();
> }
> public void paint(Graphics g)
> {
> if (TD)
> {
> TableroGif = getImage(getCodeBase(), "Tablero.gif");
> Tablero_Buffer.drawImage (TableroGif, 0, 0, this);
> Tablero_Buffer.fillRect(0,0,32,420);
> }
> g.drawImage (TableroImg, 0, 0, this);
> TD=false;
> }
> }
How does your code know if you've called drawImage on object g before?
You might be passing in different g objects with each paint() call?
If you wish to load the gif only once, can't you do that in the init()
method? (I'm not applet savy, perhaps there's a reason why you can't
load it in the init, but I have to ask anyway.)
Perhaps you want to create and draw into that buffer only once, in the
init(), and simply repaint it onto every g object?
> If I erase the last line "TD=false" it works fine.
> But I need that line because I want to draw the image only once.
Hrm. I don't think you can really do this. I think your paint()
method is supposed to assume that its entire coordinate space has
been erased and it needs to rebuild it all. You have to redraw
the whole image every time.
> Thank you, I will ensure the gif has completely loaded before
> attempting to display it.
--
Joi Ellis (TeamB)
No direct email, please.
For best results, post on news server newsgroups.borland.com!
Newsgroup Info: http://www.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<3ac4cec4_2@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!bignews.mediaways.net!newsfeed00.sul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews!not-for-mailReferences:
<3AC361A6.21A4F47E@rslcom.es> <3ac36a85_1@dnews> <3AC46592.98908578@rslcom.es>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,e3fc9de084362442
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-30 10:34:15 PST
Message-ID: <3ac4cec4_2@dnews>
From: "Joi Ellis [TeamB]" <joi@aravox.com>
Subject: Re: DESPERATE !!!
Newsgroups: borland.public.jbuilder.java.language
References: <3AC361A6.21A4F47E@rslcom.es> <3ac36a85_1@dnews> <3AC46592.98908578@rslcom.es>
User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.16-3 (i686))
NNTP-Posting-Host: 209.46.41.66
Date: 30 Mar 2001 10:21:57 -0800
X-Trace: 30 Mar 2001 10:21:57 -0800, 209.46.41.66
Lines: 58
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!bignews.mediaways.net!newsfeed00.sul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews!not-for-mail