Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Images won't load from constructor! Why not?

0 views
Skip to first unread message

Martin Rebas

unread,
Mar 30, 1997, 3:00:00 AM3/30/97
to


I'm writing a game applet, in which I have a couple of enemies
moving about. I've created a separate class for the enemies, and added
methods for moving and drawing them.

Everything worked well, until I moved the code which loads the graphics
for the enemies from the "Game" class to the Enemy class constructor.
(I also had to make the Enemy class a subclass of Applet, since I use
getImage).

It compiled OK, but when I tried to run it, it caused an exception.

java.lang.IllegalArgumentException: Argument # > Arg length
at java.text.MessageFormat.format(MessageFormat.java)
at java.text.MessageFormat.format(MessageFormat.java)
at java.text.Format.format(Format.java)
at sun.applet.AppletMessageHandler.getMessage(AppletMessageHandler.java:63)
at sun.applet.AppletMessageHandler.getMessage(AppletMessageHandler.java:78)
at sun.applet.AppletPanel.showAppletStatus(AppletPanel.java:554)
at sun.applet.AppletPanel.run(AppletPanel.java:330)
at java.lang.Thread.run(Thread.java)

Why?

The source can be found at:
http://www.dtek.chalmers.se/~d3rebas/Java2/Virus.java

The exception is caused by the line "virusImgs = getImage(getDocumentBase(), "http://www.dtek.chalmers.se/~d3rebas/Java2/Data/virus.gif");"

I have a feeling that getDocumentBase() doesn't return anything, but I
could be wrong. And I still don't know why.

/Martin

--
Martin Rebas My home page. Visit it. Comics, comic
d3r...@dtek.chalmers.se reviews, atheism, pi, weird stuff.
------------------------ Tremendously stupid.
www.dtek.chalmers.se/~d3rebas/ Also, no annoying sentence fragments.

Martin Rebas

unread,
Mar 30, 1997, 3:00:00 AM3/30/97
to

d3r...@dtek.chalmers.se (Martin Rebas) writes:


>(I also had to make the Enemy class a subclass of Applet, since I use
>getImage).


// Public apology

for(int i=0; i<1000; i++) {
System.out.println("Never again will I make my enemy classes
subclasses of Applet.");
}


The problem has been fixed. No need to mail me.

0 new messages