package com.kuang.lesson1; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class TestBorderLayOut { public static void main(String[] args) { Frame frame=new Frame("BorderLayOut"); //组件按钮 Button EAST=new Button("EAST"); Button WEST=new Button("WAST"); Button CENTER=new Button("CENTER"); Button SOUTH=new Button("SOUTH"); Button NORTH=new Button("NORTH"); //设置流式布局 默认是靠中 //frame.setLayout(new FlowLayout()); frame.setSize(300,300); frame.add(EAST,BorderLayout.EAST); frame.add(WEST,BorderLayout.WEST); frame.add(CENTER,BorderLayout.CENTER); frame.add(SOUTH,BorderLayout.SOUTH); frame.add(NORTH,BorderLayout.NORTH); frame.setVisible(true); frame.addWindowListener(new WindowAdapter() { //窗体关闭时做的事 @Override public void windowClosing(WindowEvent e) { // super.windowClosed(e); System.exit(0); } } ); } }
标签:lesson2,BorderLayOut,frame,BorderLayout,add,东西南北中,new,Button,SOUTH From: https://www.cnblogs.com/zym97816/p/17734565.html