File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "AWT" Watch "AWT" New topic


jeena jose
Ranch Hand

Joined: May 06, 2001
Posts: 69
Consider the following program...
import java.awt.*;
public class MyFrame
public static void main(String[] args)
Frame fr = new Frame();
Panel p = new Panel();
Button b1 = new Button("North");
Button b2 = new Button("South");
fr.add("North", p);
fr.add("South", b2);
on resizing width of North will not change.why???
Sharada Kumaran

Joined: May 23, 2001
Posts: 29
The buttons are added to the panel using FlowLayout (the default layout for Panels). FlowLayout honors the preferred size of the component, and will not resize the component even when its container changes size. The panel is added to the Frame using BorderLayout. On resizing the Frame, the panel might get resized, but the button in the panel is not affected. Infact, that is the primay advantage of adding components to a Panel, as opposed to adding it directly to the Frame.
Hope I could clear your doubt.

I agree. Here's the link:
subject: AWT
It's not a secret anymore!