Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » requesting help with eclipse and using resources
requesting help with eclipse and using resources [message #202965] Tue, 10 May 2005 08:30 Go to next message
Eclipse UserFriend
Originally posted by: plongo99.hotmail.com

i am working my way through the sun tutorial on swing and am having a
problem with one of the examples
( http://java.sun.com/docs/books/tutorial/uiswing/learn/exampl e5.html).

my problem is that the ptogram can not find the external image files used in
the dialog boxes.

the problem seems to be that i do not know how to tell eclipse where i have
put the image files.

the relevant bits of code seem to be:

// get the images and put them in an array of ImageIcons
for (int i = 0; i < NUM_IMAGES; i++){
images[i] = createImageIcon("images/image" + i + ".jpg");
}

and then latter ...

// returns an image icon or null if unable to locate resource
protected static ImageIcon createImageIcon(String path){
URL imageURL = LunarPhases.class.getResource(path);
//URL imageURL = LunarPhases.class.getResource("/images/image0.jpg");

if (imageURL == null) {
System.err.println("Resource not found: " + path);
return null;
} else {
return new ImageIcon(imageURL);
}
}

what i did ...
i created a new project in eclipse, then right-mouse buttoned the project
name in eclipse and created a new folder in the project. then i transfered
the image files to the newly created image folder, created the new class,
etc.,

when i run the program i get an error message saying the image files can not
be found.

any help would be greatly appreciated.
Re: requesting help with eclipse and using resources [message #203175 is a reply to message #202965] Wed, 11 May 2005 21:59 Go to previous message
Thorbjørn Ravn Andersen is currently offline Thorbjørn Ravn AndersenFriend
Messages: 27
Registered: July 2009
Junior Member
pat wrote:

> what i did ...
> i created a new project in eclipse, then right-mouse buttoned the project
> name in eclipse and created a new folder in the project. then i transfered
> the image files to the newly created image folder, created the new class,
> etc.,

Try creating a new source folder in addition to the one containing your
Java source, and create a new folder named "images" inside of it. Copy
your images to there, and run your program again.

--
Thorbjørn
Previous Topic:Is one class a superclass of another?
Next Topic:Going back to JDT from CDT
Goto Forum:
  


Current Time: Thu Jul 18 04:44:08 GMT 2024

Powered by FUDForum. Page generated in 0.02992 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top