📄 showborderlayout.java
字号:
/*
* ShowBorderLayout.java
*
* Created on 2007年10月20日, 下午11:01
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
*
* @author admin
*/
public class ShowBorderLayout extends JFrame{
/** Creates a new instance of ShowBorderLayout */
public ShowBorderLayout() {
//获取窗口的内容面板
Container container = this.getContentPane();
//设置Gridlayout: 水平间距5/垂直间距10
container.setLayout(new BorderLayout(5, 10));
//添加按钮到Frame
container.add(new JButton("East"), BorderLayout.EAST);
container.add(new JButton("South"), BorderLayout.SOUTH);
container.add(new JButton("West"), BorderLayout.WEST);
container.add(new JButton("North"), BorderLayout.NORTH);
container.add(new JButton("Center"), BorderLayout.CENTER);
}
public static void main(String[] args) {
ShowBorderLayout frame = new ShowBorderLayout();
frame.setTitle("网格布局");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -