File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes how to use image ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to use image ?" Watch "how to use image ?" New topic

how to use image ?

mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
i want to implement a graphic image which would be contained inside a frame or panel, may be like a canvas. how to use an image as a canvas like a background upon which i want to place other components ?
also what should be the format of the image ? jpg is ok ?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

If you just want to use a background image, and if you are using Swing, you can just put the image on the JPanel using a JLabel.
myLabel = new JLabel(new ImageIcon("some.gif"));
myPanel.add(myLabel, new Integer(Integer.MIN_VALUE));
See if that works for you.

GenRocket - Experts at Building Test Data
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Mark,
Here is a class that you can use. It comes with an example class to see how it is used.

I agree. Here's the link:
subject: how to use image ?
It's not a secret anymore!