Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Importing images using Swing

 
T Pelly
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is probably quite a simple one:
For the program I'm writing I need to import a jpeg image and draw on top of it.
The problem is that I can't find any way to do this in swing - I know it's simple in applets, but don't even know how to import the image when using swing!
Please help!
 
Daniel Searson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get the image using:
Image image = Toolkit.getDefaultToolkit().createImage("etc.jpg");
Alternatively, you can use an image icon like this:
ImageIcon ii = new ImageIcon("etc.jpg");
Image image = ii.getImage();
Thats only available in Swing.
Daniel
[This message has been edited by Daniel Searson (edited July 09, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic