GeeCON Prague 2014*
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
Author

frames

sun par
Ranch Hand

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


Sunita<br />SCJP 1.4
Valentin Crettaz
Gold Digger
Sheriff

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.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257
Hai Valentin,
Thanks.
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
2.Window.
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
Johnson
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: frames