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 awt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "awt" Watch "awt" New topic


Asim Abbasi

Joined: Feb 24, 2004
Posts: 2
How can i set image in background of a Frame
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
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.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

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.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: awt
It's not a secret anymore!