#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    254
    Rep Power
    13

    loading image in a class?


    can you create/load image in a class and how?

    for example

    class Myclass{
    Image image;

    public Myclass(){
    URL codeBase=getCodeBase();
    image=getImage(codeBase,"image.jpg");
    }
    }

    why wont this work?
    Thanks for any help.
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    India
    Posts
    7
    Rep Power
    0
    the code wont work b'cos "getCodeBase()" function belongs to the applet class...the code for loadin the image is

    URL codeBase= new URL("file://c:/filepath/filename");
    image=getImage(codeBase,"image.jpg");

    try this it will work....
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Location
    Norway
    Posts
    1
    Rep Power
    0
    In an application you may use the following to load an image into a class:
    Image image = Toolkit.getDefaultToolkit ().getImage ("your_picture.gif");

IMN logo majestic logo threadwatch logo seochat tools logo