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 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 Murach's Java Servlets and JSP this week in the Servlets 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
Author

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

regards


if (!WorkHard){
System.out.println("Fail!!!");
}
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
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!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to Create Image In a Frame
 
Similar Threads
Image in JFrame ???
Stretch the image size.
awt
splash screen
desktop ScreenShot