Drawing Images in an Application

I've been pulling my hair out and can find no answer to my question. I just read through the message boards and I am having the same problem as the user "Requiem". I would like to be able to draw an image on a panel (a gif to be specific). I read in a book about how to use the Toolkit class but the book unfortunately did not provide a full working example. I can get my code to draw strings to my panel but not an image. Can anyone give me a basic working example of drawing an image on a panel or jpanel or give me help in finding the code to do so? Any help is greatly appreciated.

Comments

  • : I've been pulling my hair out and can find no answer to my question. I just read through the message boards and I am having the same problem as the user "Requiem". I would like to be able to draw an image on a panel (a gif to be specific). I read in a book about how to use the Toolkit class but the book unfortunately did not provide a full working example. I can get my code to draw strings to my panel but not an image. Can anyone give me a basic working example of drawing an image on a panel or jpanel or give me help in finding the code to do so? Any help is greatly appreciated.
    :
    To draw an image on a panel u need to use the paint method. First u need to load the image with for example mediatracker. Then u need to override the paint method
    public void paint(Graphics g) {
    g.drawImage(i,0,0,this)
    }
    I have an essay where i show you it but i am still working on it because i have some bugs with it. The painting is fine but i cannot send it yet because this pc is a bit slow but when i am at school i can send it just leave a msg if u want it at giga19@hotmail.com
    Enjoy
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion