This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Create Image In a Frame

 
Koh Khai Huat
Ranch Hand
Posts: 100
  • 0
  • 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: 20380
45
Chrome Eclipse IDE Java Windows
  • 0
  • 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
  • 0
  • 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:
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic