6
6e
Hi, Im having a slight problem.
I am trying to load an image object with the code below, and I am NOT
extending Applet in my class because I am working on an application.
The problem is that getCodeBase AND getDocumentBase are not being
recognized by my application, however I am sure that the required jars
are in the build path... and that I've referenced them... most likely
inapproprirately.
My code is set up like this
Base\
Base\graphics\img.gifs.
Code follows, I trimmed the imports mostly off, but the rest appear
below the code...
Thanks for your advice.
import java.net.URL;
import java.applet.Applet;
.............
String strImageUp = "graphics/up.gif";
URL urlUp = getClass().getResource(strImageUp);
Image imgUp = null;
try {
MediaTracker m = new MediaTracker(this);
imgUp = getImage(getDocumentBase(), strImageUp);
m.addImage(imgUp, 0);
m.waitForAll();
}
catch (Exception e) {
e.printStackTrace();
}
.................
import javax.crypto.interfaces.PBEKey;
import javax.imageio.*;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import java.util.LinkedList;
import java.util.ListIterator;
import java.awt.event.ActionListener; //for buttons
import java.awt.event.ActionEvent; //for button events
import java.awt.event.KeyEvent; //for key shortcuts
import java.math.*; //percentage rounding
I am trying to load an image object with the code below, and I am NOT
extending Applet in my class because I am working on an application.
The problem is that getCodeBase AND getDocumentBase are not being
recognized by my application, however I am sure that the required jars
are in the build path... and that I've referenced them... most likely
inapproprirately.
My code is set up like this
Base\
Base\graphics\img.gifs.
Code follows, I trimmed the imports mostly off, but the rest appear
below the code...
Thanks for your advice.
import java.net.URL;
import java.applet.Applet;
.............
String strImageUp = "graphics/up.gif";
URL urlUp = getClass().getResource(strImageUp);
Image imgUp = null;
try {
MediaTracker m = new MediaTracker(this);
imgUp = getImage(getDocumentBase(), strImageUp);
m.addImage(imgUp, 0);
m.waitForAll();
}
catch (Exception e) {
e.printStackTrace();
}
.................
import javax.crypto.interfaces.PBEKey;
import javax.imageio.*;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import java.util.LinkedList;
import java.util.ListIterator;
import java.awt.event.ActionListener; //for buttons
import java.awt.event.ActionEvent; //for button events
import java.awt.event.KeyEvent; //for key shortcuts
import java.math.*; //percentage rounding