DZone Forums
Go Back   DZone Forums > Community > Languages & Frameworks > Java
Reload this Page How do I specify a path for SWT ImageLoader?
Notices
Reply
 
LinkBack Thread Tools Display Modes
  (#1 (permalink)) Old
Member
 
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: May 2008
Default How do I specify a path for SWT ImageLoader? - 05-11-2008, 06:21 PM

I am trying to use import org.eclipse.swt.graphics.ImageLoader to import an animated gif file.

The command given to me is this:

Code:
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class Snippet141 {
	static Display display;
	static Shell shell;
	static GC shellGC;
	static Color shellBackground;
	static ImageLoader loader;
	static ImageData[] imageDataArray;
	static Thread animateThread;
	static Image image;
	static final boolean useGIFBackground = false;
	
	public static void main(String[] args) {
		display = new Display();
		shell = new Shell(display);
		shell.setSize(300, 300);
		shell.open();
		shellGC = new GC(shell);
		shellBackground = shell.getBackground();

		FileDialog dialog = new FileDialog(shell);
		dialog.setFilterExtensions(new String[] {"*.gif"});
		String fileName = dialog.open();
		if (fileName != null) {
			loader = new ImageLoader();
			try {
				imageDataArray = loader.load(fileName);
Which is fine if I want to use a file dialog to find the file, but what if I don't. How I specify the file itself. I have tried putting the class in the same folder as the icons but nothing seems to work. it keeps giving me a file not found error.

Say for example I had the images located underneath this class in a sub folder called "gif", how would I tell this class to go an look in there for it?

The loader.load(fileName) only accepts a string which as far as I can work out must point directly to where the file is including the full path name (unless I'm completely wrong here).

Any help appreciated.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(commons-bean) howto print all bean properties path? edmund Java 0 12-15-2008 03:18 AM
eclipse/vistajava.lang.NoClassDefFoundError: –Djava/library/path=//lib Exception main adhoul Eclipse 1 11-15-2008 11:52 AM
why aren't plugins in my build path? Greg.Dorval Eclipse 0 09-19-2008 03:54 PM
How can i know the path of the file opened in editor??? rajeshgubba Eclipse 1 04-24-2008 07:17 AM
Can't remove j2ee.jar from build path joezaloom Eclipse 1 02-12-2008 08:46 PM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com