📄 showflowlayout.java
字号:
/*
* ShowFlowlayout.java
*
* Created on 2007年10月20日, 下午10:39
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
*
* @author admin
*/
public class ShowFlowLayout extends JFrame{
/** Creates a new instance of ShowFlowlayout */
public ShowFlowLayout() {
//获取窗口的内容面板
Container container = this.getContentPane();
//设置Flowlayout: 左对齐/水平间距10/垂直间距20
container.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
//添加按钮到Frame
for (int i = 1; i <= 10; i++) {
container.add(new JButton("Component "+i));
}
}
public static void main(String[] args) {
ShowFlowLayout frame = new ShowFlowLayout();
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 + -