码迷,mamicode.com
首页 > 其他好文 > 详细

SWT LAYOUT

时间:2021-05-24 10:44:34      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:listen   adapter   sys   mic   ati   color   listener   tla   enter   

layout可以叠加效果

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class HomeWork {

    public static void main(String[] args) {
        Frame frame = new Frame();
        frame.setSize(400,400);
        frame.setLocation(300,300);
        frame.setBackground(Color.black);
        frame.setVisible(true);
        frame.setLayout(new GridLayout(2,1));

        Panel panel1 = new Panel(new BorderLayout());
        Panel panel2 = new Panel(new GridLayout(2, 1));
        Panel panel3 = new Panel(new BorderLayout());
        Panel panel4 = new Panel(new GridLayout(2, 2));

        panel1.add(new Button("east-1"),BorderLayout.EAST);
        panel1.add(new Button("west-1"),BorderLayout.WEST);
        panel2.add(new Button("p2-b1"));
        panel2.add(new Button("p2-b2"));
        panel1.add(panel2,BorderLayout.CENTER);

        panel3.add(new Button("east-2"),BorderLayout.EAST);
        panel3.add(new Button("west-2"),BorderLayout.WEST);
        panel4.add(new Button("p2-b1"));
        panel4.add(new Button("p2-b2"));
        panel4.add(new Button("p2-b3"));
        panel4.add(new Button("p2-b4"));
        panel3.add(panel4,BorderLayout.CENTER);

        frame.add(panel1);
        frame.add(panel3);

        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });


    }
}

效果
技术图片

SWT LAYOUT

标签:listen   adapter   sys   mic   ati   color   listener   tla   enter   

原文地址:https://www.cnblogs.com/pipacam/p/14771740.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!