The default layout manager for the panel is the FlowLayout layout manager. The panel is constructed in two ways: the public panel (LayoutManager layout) creates a panel with the specified layout manager, public panels (), and creates a panel with the default layout manager, The default layout manager for all panels is the FlowLayout class. Layout Manager Summary: Frame is a top-level window, frame's default layout manager is BorderLayout panel cannot be displayed separately, must be added to the container in the default layout manager for panel FlowLayout when you add a panel as a component to a container, the panel can still have its own layout manager. When you use the Layout manager, the layout manager is responsible for the size and location of each component, so that users cannot set the component size and location properties in this case.
If you use methods such as setlocation (), SetSize (), SetBounds (), which are provided using the Java language, the layout manager overrides. If you do need to set the component size and location yourself, you should cancel the container's layout manager by: setlayout (NULL);
*/
Import java.awt.*;
public class Testnestedlayout { public static void main (string[] args) { frame f = new Frame ("Testnestedla Yout "); f.setlocation (+); f.setsize (+); f.setbackground (New Color ( 204, 204, 255); f.setlayout (New GridLayout (2, 1)); panel P1 = new Panel (new BorderLayout ()); panel P2 = new Panel (new BorderLayout ()); panel p3 = new Panel (new GridLayout (2, 1 ); panel P4 = new Panel (New GridLayout (2, 2)) p1.add (New button ("button"), borderlayout.west); p3.add ("button") p3.add (New button ("button")), p1.add (P3, Borderlayout.center) p1.add (New button ("button"), borderlayout.east); p2.add ( New button ("button"), borderlayout.west); p4.add (New button ("button")); p4.add ( New button ("button") p4.add ("button"); p4.add (new Button ("button"), p2.add (P4, Borderlayout.center); p2.add ("button" ), borderlayout.east); f.add (p1); f.add (p2); f.setvisible (true);
}}
Summary of layout Manager for Java language GUI programming