wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How do I place image in the background of JFrame ? 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 do I place image in the background of JFrame ?" Watch "How do I place image in the background of JFrame ?" New topic
Author

How do I place image in the background of JFrame ?

raj varma
Greenhorn

Joined: Jan 05, 2003
Posts: 28
How do I place image in the background of JFrame ?
I have tried the following but it is not working.
Please Help !

[ May 05, 2003: Message edited by: raj varma ]
indian greenhorn
Greenhorn

Joined: May 01, 2003
Posts: 16
Hello, it is not possible to put the image directly on the JFrame or on a JPanel. One way to make it is to set the image (should have good size)on a JLabel and when you add the JLabel it will appear as it is a background image. You can also add components over this image. This way you can achieve your requirement of background image to the JFrame.
regards
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You can't draw it to the JFrame itself (just like the previous poster said), but instead of using JLabel, I would create a custom panel to display the image so I could add components on top of it easily. Then you can set that panel as the content pane of the frame. Below is some code I had that shows how to do this:



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I place image in the background of JFrame ?
 
Similar Threads
How to Tile an Image on a JLabel or a JPanel?
cannot draw graphics
Java ME game creation help
How to put image as background image in JPanel.
painting custom components without extending jcomponent