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.