I thought that too.
After code, compile and ran it, it shows an empty window.
Here's why:
1.- The frame is made visible before the buttons are added, so when it is drawn there's no buttons to show.
2.- The buttons are added to the frame, but as the frame has already been drawn thus they are not showed, if you resize the window with the mouse the B button will appear occupying the whole frame this is because when the frame is changes its size
paint method is called and the button that were added is painted too.
as demo here's a modified code:
Originally posted by Neha Sawant:
public class FrameTest extends Frame{
public FrameTest(){
super("FrameTest");
setSize(300,400)
setVisible(true);
Componrnt b=new Button("B");
Component c=new Button("C");
add(c);
add(b);
}
public static void main(String srgs[]){
FrameTest f=new FrameTest();
}
}
Answer given empty window is displayed.
I feel button B should occupy the whole frame
[This message has been edited by Zkr Ryz (edited November 07, 2001).]