This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes frames Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "frames" Watch "frames" New topic


sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257
Can frames be added to another container?

Sunita<br />SCJP 1.4
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
No, an IllegalArgumentException will be thrown if you try to add any type of Window to a Container. You should try to write the code before asking this kind of question, you would have found the answer very quickly. The code is as simple as this:

Never forget that practicing is the key to your success.

[Blog] [Blogroll] [My Reviews] My Linked In
sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257
Hai Valentin,
Johnson K Jose
Ranch Hand

Joined: Jul 07, 2002
Posts: 36
Hi sunita,
Some more tips....
Basically a container is a component that can accommodate other components and containers.
This will provide support for building complex hierarchical GUIs.
The abstract class Container has two sub classes
1.Panel and
Sub class of panel is Applet and That of Window class is Frame and Dialog.
In general there are two types of containers, one can exist by it�s own and the other can not.
One can exist by its own is known as a "Top Level Window". Example Window and its sub classes (Frame and Dialog).
And for the other type Example is Frame class.
A Top Level container (Window) can not be incorporated in to other type of containers (This is the answer to your question!),
But it can contain other "non Top Level container", example a frame can contain Panel, but not in the other way!.
In that case it will throw an IllegalArgumentException (as Mr.Valentin Crettaz mentioned)
Hope this will help you
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: frames
It's not a secret anymore!