Results 1 to 5 of 5

Thread: Problem with createImage() in Java Application

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Problem with createImage() in Java Application

    I am trying to convert a Java Applet to a Java Application. In the Applet there is the following...
    Code:
      '
      '
    Image offscreenImg;
      '
      '
    offscreenImg = createImage(124, 180);
      '
      '
    Now this works perfectly and the Applet runs the way it should.

    In the Java Application I am doing this....
    Code:
      '
      '
    Image offscreenImg;
      '
      '
    offscreenImg = Toolkit.getDefaultToolkit().createImage(124, 180);
      '
      '
    I use the Toolkit.getDefaultToolkit() because I think this is what I have to do but when I compile the Application I get the following error:

    error J0078: Class 'Toolkit' doesn't have a method that matches 'createImage(int, int)'

    So, I looked up createImage on the Net and the information there said that createImage is a method of Toolkit. When I scaned all the methods I only found the following:

    createImage(byte[] imagedata)
    createImage(String filename)
    createImage(URL url)
    createImage(byte[] imagedata, int imageoffset, int imagelength)
    createImage(ImageProducer producer)

    So I see there is no method createImage(int, int).

    So, my question is why does it compile and run OK in the Applet but it won't compile in the Application? Why does the Applet have createImage(int, int) but it does not exist in the Toolkit for the Application?

    Here is the link for the information:

    http://java.sun.com/j2se/1.4.2/docs/...t/Toolkit.html

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Problem with createImage() in Java Application

    Because the "createImage(int, int)" you're calling is in the java.awt.Component class which is the super class for the Applet class.
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Problem with createImage() in Java Application

    That's the way I had it to begin with. It compiles error free but when run the app offscreenImg comes out null.

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Problem with createImage() in Java Application

    You're missing the main point. the createImage(int, int) is not a member of the Toolkit class.
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Problem with createImage() in Java Application

    I originally had it as a member of Components but it didn't work so I thought it might be a member of Toolkit instead so I changed it in my code but then I got error

    error J0078: Class 'Toolkit' doesn't have a method that matches 'createImage(int, int)'

    then you said

    Because the "createImage(int, int)" you're calling is in the java.awt.Component class which is the super class for the Applet class

    and then I said

    That's the way I had it to begin with. It compiles error free but when run the app offscreenImg comes out null.

    so what point am I missing?
    Last edited by jmsrickland; Feb 28th, 2008 at 09:44 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width