🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #659

Re: Background image not showing up in Designer

#659
From: Scott Wells
Date: Tue, 01 Apr 2003 23:28
90 lines
2940 bytes
Okay, I got a bit further. I created a new panel class that extends
JPanel:

import java.awt.*;
import javax.swing.JPanel;

public class UFTPanel extends JPanel
{
  private Image image = null;
  public UFTPanel()
  {
  }

  public UFTPanel( Image image )
  {
    this();
    setImage( image );
    this.repaint();
  }

  public Image getImage()
  {
    return image;
  }

  public void setImage( Image newImage )
  {
    this.image = newImage;
  }

  public void paint( Graphics g )
  {
    if (image != null)
    {
      g.drawImage(image, 0, 0, this);
    }
  }
}
-----

Now, in my applet, I have:
    Image bkgd = null;

 bkgd = getImage(new
URL("file:/home/swells/UFT/UFTJavaProject/classes/desaltemplate.jpg"));
 panel2.setImage(bkgd);
----
During run time, the image shows up fine, but during desing time, when
I switch to the Design tab, I get the following error: 'null invoking
getImage(new URL("file:/home/swells/UFT/UFTJavaProject/classes/desaltemplate.jpg"));'

I'm at my wits end here. I don't understand why the picture isn't
showing up.
I tried using getCodeBase(), but I got: 'null invoking getCodeBase()'.

Please, any suggestions?

Thanks,

Scott




swells@merxyn.com (Scott Wells) wrote in message news:<86952eb4.0304011100.551a5b5d@posting.google.com>...
> Hello, I've placed a panel on my applet form and wanted to add a
> background to it so I can place components (buttons, etc) at
> appropriate spots on the image.
> 
> I can get the image to show up during run time, but not at design
> time. To get the  image as a background, I did the following:
> 
> public class UFTApplet extends Applet {
>   Panel panel2 = new Panel()
>   {
>     public void paint(java.awt.Graphics g)
>     {
>            Image bkgd = getImage(getCodeBase(), "desaltemplate.jpg");
> 
>            super.paint(g);
>            g.drawImage(bkgd, 0, 0, this);
>     }
>   };
> 
> How can I get the designer to load the image so I can place components
> on it?
> 
> Thank you.
> 
> Scott
Technical Details
Message-ID: <86952eb4.0304011528.53d59254@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
References: <86952eb4.0304011100.551a5b5d@posting.google.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,4b21efc39bf0a3ad
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2003-04-01 15:28:34 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
From: swells@merxyn.com (Scott Wells)
Newsgroups: borland.public.jbuilder.java.api
Subject: Re: Background image not showing up in Designer
Date: 1 Apr 2003 15:28:33 -0800
Organization: http://groups.google.com/
Lines: 90
Message-ID: <86952eb4.0304011528.53d59254@posting.google.com>
References: <86952eb4.0304011100.551a5b5d@posting.google.com>
NNTP-Posting-Host: 65.71.89.122
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1049239714 9237 127.0.0.1 (1 Apr 2003 23:28:34 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 1 Apr 2003 23:28:34 GMT