Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

awt

 
Asim Abbasi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i set image in background of a Frame
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't really anything to do with servlets, so I've moved it to our Swing/AWT forum, where you should get more useful answers.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For an AWT frame all you need to do is override the paint( Graphics ) method of the frame to draw your image. You can either hardcode the image somewhere (like the constructor of the frame subclass) or have a pair of setImage()/getImage() methods.



However, Swing presents a better solution... since AWT uses native components, child components in the Frame will cover up the background image. Swing allows most child components to call setOpaque( false ) and allow their parent's background to show through. I have covered the way to do this in Swing here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic