🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8317

Re: DESPERATE !!!

#8317
From: Carlos Ojea Castro
Date: Fri, 30 Mar 2001 10:53
83 lines
3067 bytes
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;
   }
}


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.

Thank you, I will ensure the gif has completely loaded before
attempting to display it.

Best regards.


"Joi Ellis [TeamB]" wrote:

> Carlos Ojea Castro <ccastro@rslcom.es> wrote:
>
> > Hello :
>
> > I don't understand anything !!.
> > This peace of code in my paint() method draws a gif and
> > a black rectangle :
>
> >    TableroGif = getImage(getCodeBase(), "Tablero.gif");
> >    Tablero_Buffer.drawImage (TableroGif, 0, 0, this);
> >    Tablero_Buffer.fillRect(0,0,32,42);
>
> > But this other code only draws the black rectangle, and
> > not the image !!!! :
>
> > if (TD)
> > {
> >    TableroGif = getImage(getCodeBase(), "Tablero.gif");
> >    Tablero_Buffer.drawImage (TableroGif, 0, 0, this);
> >    Tablero_Buffer.fillRect(0,0,32,42);
> > }
>
> > Of course TD is true. TD is a class variable.
>
> Is that the exact code?
>
> Two things I'd check for:
>
>   Ensure the gif file has completely loaded before you attempt to display it.
> There is an image loader class which tracks this for you.
>
>   Check the scope of your variables and make sure something isn't being
> defined within the IF block and thus disappearing when the IF block scope
> ends.
>
> --
> 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: <3AC46592.98908578@rslcom.es>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!zeus.visi.com!news-out.visi.com!hermes.visi.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews!213.250.128.151
References: <3AC361A6.21A4F47E@rslcom.es> <3ac36a85_1@dnews>

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 03:18:05 PST
Message-ID: <3AC46592.98908578@rslcom.es>
Date: Fri, 30 Mar 2001 12:53:07 +0200
From: Carlos Ojea Castro <ccastro@rslcom.es>
X-Mailer: Mozilla 4.74 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: DESPERATE !!!
References: <3AC361A6.21A4F47E@rslcom.es> <3ac36a85_1@dnews>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 213.250.128.151
X-Trace: 30 Mar 2001 02:52:52 -0800, 213.250.128.151
Lines: 84
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!zeus.visi.com!news-out.visi.com!hermes.visi.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews!213.250.128.151