Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "AWT" Watch "AWT" New topic
Author

AWT

Arun Pai
Ranch Hand

Joined: Mar 11, 2002
Posts: 143

Attemping to compile and run the above code

1.Will cause a compilation error - a Layout cannot be set after a component has been added with a preset Layout Manager.
2.Will cause a Runtime Exception - a Layout cannot be set after a component has been added with a preset Layout Manager.
3.Will compile cleanly and throw no runtime Exception. Only the button with label "Center" is visible and occupies the whole screen.
4.Will compile cleanly an throw no runtime Exception. All the buttons are arranged in a single line. Any other component added in future will follow the rules of the BorderLayout Manager.
5.Will compile and run cleanly, but no component is visible.
6.Will compile cleanly and throw no runtime Exception. The buttons are arranged as listed below
Button Label Position
Center Center
North North
South South
East East
West West
ans is 5, why the component is not displayed?
-Arun
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
BorderLayout and CardLayout are the uniques AWT LayoutManagers that don't know how to rearrange components previously added.


SCJP2. Please Indent your code using UBB Code
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: AWT
 
Similar Threads
layout managers
about frame &Layout
Layout Qstn
Flow layout
Abhilash #39 - layout managers