Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Create Image In a Frame

 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rob Spoor
Sheriff
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) use an ImageIcon object inside a JLabel
2) use paintComponent (for Swing) that draws an Image on the Graphics object
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic