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 Create Image In a Frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to Create Image In a Frame" Watch "How to Create Image In a Frame" New topic

How to Create Image In a Frame

Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi guys

i need help on how to Create Image In a Frame or set the frame's background as the Image.

sample code will be gladly Aprecitated thanks


if (!WorkHard){
Rob Spoor

Joined: Oct 27, 2005
Posts: 19908

1) use an ImageIcon object inside a JLabel
2) use paintComponent (for Swing) that draws an Image on the Graphics object

How To Ask Questions How To Answer Questions
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Iv'e found that a flexible way to create a background image on a Swing
container is to define a border and have it draw the image:This way you don't have to subclass the contain in order to give it a
background image. Demo:

There is no emoticon for what I am feeling!
Consider Paul's rocket mass heater.
subject: How to Create Image In a Frame