Image loading

S

s.magnien

Hi all.
What I'd like would be two classes:

public class Main extends java.applet.Applet
{
Room current_room;
.....
}

and

public class Room extends java.applet.Applet
{
//loads images
public void Paint(Graphics g)
{
g.drawImage(//loaded images...);
}
}

I have this working _provided_ the images are loaded through Room's
constructor Room, something like

Room(Images[]), when Main does

current_room=new Room(Images[]); in its init method.

I would like Room to load its images on its own. I tried loading them
in Room(), in init(), in Paint(), devising a custom loading function,
but nothing works. I'm fairly sure the images are loaded, as catch
doesn't return any problems, but they won't draw _except_ if the images
are loaded through Room()'s constructor.

Is this construct wrong? (if so, sorry, I am a two-day old java "coder"
;) ) If it ain't, what am I missing?

Thank you all!
 
A

Andrew Thompson

(if so, sorry, I am a two-day old java "coder"
;) ) If it ain't, what am I missing?

Post an SSCCE[1] (with URL) to c.l.j.help[2] and I will provide assistance.
But please first read the info on applets[3], painting[4] and
image loading[5] and tracking[6] first.

[1] <http://www.physci.org/codes/sscce.jsp>
[2] <http://www.physci.org/codes/javafaq.jsp#cljh>
[3] <http://java.sun.com/docs/books/tutorial/applet/index.html>
[4] <http://java.sun.com/docs/books/tutorial/uiswing/14painting/index.html>
[5] <http://java.sun.com/docs/books/tutorial/2d/overview/images.html>
[6] <http://java.sun.com/j2se/1.5.0/docs/api/java/awt/MediaTracker.html>

( shrugs.. I have dealt with a few too many
'2 day old applet programmers' recently ;)
 
S

s.magnien

Thank you; I wasn't aware of c.l.j.h - I will post there a short
compilable code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top