Summary of layout Manager for Java language GUI programming

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.