Image loading

Discussion in 'Java' started by s.magnien@gmail.com, Jun 5, 2005.

  1. Guest

    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!
    , Jun 5, 2005
    #1
    1. Advertising

  2. On 5 Jun 2005 15:02:41 -0700, wrote:

    > (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 ;)

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane
    Andrew Thompson, Jun 5, 2005
    #2
    1. Advertising

  3. Guest

    Thank you; I wasn't aware of c.l.j.h - I will post there a short
    compilable code.
    , Jun 6, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,252
    Kartic
    Jan 26, 2005
  2. David Segall
    Replies:
    2
    Views:
    429
    Thomas Kellerer
    Jan 2, 2007
  3. Replies:
    4
    Views:
    298
  4. edfialk
    Replies:
    0
    Views:
    177
    edfialk
    May 10, 2007
  5. ofir
    Replies:
    0
    Views:
    178
Loading...

Share This Page