[4911] in java-interest
How to load image in "stand-alone" Java app. under Win95??
daemon@ATHENA.MIT.EDU (ben.lam)
Fri Jan 19 23:56:07 1996
To: java-interest <java-interest@java.Eng.Sun.COM>
From: "ben.lam" <ben.lam@ac.com>
Date: 20 Jan 96 1:26:24
I have this stand-alone application which has problems loading image. Any help
is appreciated.
My main public class inherits from Applet class even though I start it as a
stand-alone application. That's because I want the app to be able to start as
a stand-alone app, as well as an applet.
Now my program works fine if I start it as an applet. But if I try to start it
as an stand-alone app, it cannot load the image. Even though I pass the applet
instance from the main class all the way down to my Partition class, but if I
start it as a stand-alone app, I can't use the getimage() method. So I try to
use the following statement:
curimage = (Image) Toolkit.getDefaultToolkit().
createImage(new URLImageSource(new
URL("file:///c:/data/ben/image/rock.gif")));
This statement works if I execute the program as a applet. But if I execute
the program as stand-alone, it doesn't work. That's because somehow I can't
get the toolkit with Toolkit.getDefaultToolkit(). It will generate the null
pointer exception.
So I'm at a complete lost here. I don't know exactly what's a toolkit. ANd
don't know how to load an image into my program if I execute it as a
stand-alone app.
---Ben Lam
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com