This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 15299

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.

subject: how to use image ?
Similar Threads
Image from Canvas
what is the swing of canvas ?
Getting image using tomcat webserver
hi helpme
How do I put an image on a canvas?