Originally posted by Cristi Tudose:
Atin&Prashant
I admited i'm not study complet this part(AWT) but... i'm a little confused about your arguments.
If you only switch the lines which set the LayoutManager could u tell me what's output.You may compile&run,but please give
me a reson
And if you know( or anybody else) some URLs where the AWT is properly treat give me a sign.
Rgds,Cristi
Originally posted by Cristi Tudose:
this is taken from a mock exam:
import java.awt.*;
public class TestFrame extends Frame
{
Button bNorth = new Button("North");
Button bSouth = new Button("South");
Button bEast = new Button("East");
Button bWest = new Button("West");
Button bCenter = new Button("Center");
public TestFrame()
{
setLayout(new FlowLayout());
add(bNorth);
add(bSouth);
add(bWest);
add(bEast);
add(bCenter);
setLayout(new BorderLayout());
validate();
setSize(300,300);
setVisible(true);
}
public static void main(String args[])
{
TestFrame tf = new TestFrame();
}
}
Attemping to compile and run the above code
#Will cause a compilation error - a Layout cannot be set after a component has been added with a preset Layout Manager.
#Will cause a Runtime Exception - a Layout cannot be set after a component has been added with a preset Layout
Manager.
#Will compile cleanly and throw no runtime Exception. Only the button with label "Center" is visible and occupies the whole screen.
#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.
#Will compile and run cleanly, but no component is visible.
#Will compile cleanly and throw no runtime Exception. The buttons are arranged as listed below
Button Label Position
CenterCenter
Noerth North
SouthSouth
EastEast
WestWest
Could someone give the explanations for the correct answer provided(#Will compile and run cleanly, but no component is visible).
thanks in advance
Cristi