Two Laptop Bag*
The moose likes Swing / AWT / SWT and the fly likes Importing images using Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Importing images using Swing" Watch "Importing images using Swing" New topic
Author

Importing images using Swing

T Pelly
Greenhorn

Joined: Jun 29, 2001
Posts: 5
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

Joined: Dec 03, 2000
Posts: 83
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).]


- Daniel
 
jQuery in Action, 2nd edition
 
subject: Importing images using Swing
 
Similar Threads
loading an image
how to achieve a code using jdk doc?
how to import background image into netbeans's Desktop application?
I have blank squares instead of Farsi characters as the text of MenuItem label on PopupMenu
Scale the image