🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.language
2 messages
2 total messages Started by Magnus Thu, 30 Jun 2005 16:42
How to load images into the code ...
#540
Author: Magnus
Date: Thu, 30 Jun 2005 16:42
31 lines
1747 bytes
Hi,

I have downloaded and start to test a PrinterFrameowrk set of classes 
that I found on JavaWorld.

In the PFPrintPreview class the image was loaded as:

firstPage.setIcon (new ImageIcon (getClass ().getResource 
("images/FirstPage.gif")));

I added the directory "images" and put the gifs there.

But JBuilder could not find the images.

I then tried the method that worked on earlier use:

firstPage.setIcon (new ImageIcon 
(printerframework.PFPrintPreview.class.getResource ("FirstPage.gif")));

How come that it didn't found them on the top code?

Dir structure

G:\jbproject\PrinterFrameWork\
G:\jbproject\PrinterFrameWork\bak
G:\jbproject\PrinterFrameWork\classes
G:\jbproject\PrinterFrameWork\src
G:\jbproject\PrinterFrameWork\src\images
G:\jbproject\PrinterFrameWork\src\printerframework

Magnus
Re: How to load images into the code ...
#541
Author: Kevin Dean [TeamB]
Date: Thu, 30 Jun 2005 19:46
64 lines
2785 bytes
Magnus wrote:

> Hi,
> 
> I have downloaded and start to test a PrinterFrameowrk set of classes
> that I found on JavaWorld.
> 
> In the PFPrintPreview class the image was loaded as:
> 
> firstPage.setIcon (new ImageIcon (getClass ().getResource
> ("images/FirstPage.gif")));
> 
> I added the directory "images" and put the gifs there.
> 
> But JBuilder could not find the images.
> 
> I then tried the method that worked on earlier use:
> 
> firstPage.setIcon (new ImageIcon
> (printerframework.PFPrintPreview.class.getResource
> ("FirstPage.gif")));
> 
> How come that it didn't found them on the top code?
> 
> Dir structure
> 
> G:\jbproject\PrinterFrameWork\
> G:\jbproject\PrinterFrameWork\bak
> G:\jbproject\PrinterFrameWork\classes
> G:\jbproject\PrinterFrameWork\src
> G:\jbproject\PrinterFrameWork\src\images
> G:\jbproject\PrinterFrameWork\src\printerframework
> 
> Magnus

Resources are found relative to the class that is attempting to load
them.

If this works:

printerframework.PFPrintPreview.class.getResource("FirstPage.gif")

then that means that the images are in the same directory
(printerframework) as the class.

If you want:

printerframework.PFPrintPreview.class.getResource("images/FirstPage.gif"
)

then you need to put the images in the directory below
(printerframework/images).
-- 
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/

NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
http://www.datadevelopment.com/papers/index.html

Please see Borland's newsgroup guidelines at
http://info.borland.com/newsgroups/guide.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads