📄 flowlayoutdemo.java
字号:
// 例6.4.1 FlowLayoutDemo.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FlowLayoutDemo
{
private JFrame jframe;
private JButton jb1,jb2,jb3,jb4,jb5;
public FlowLayoutDemo()
{
jframe = new JFrame("FlowLayout演示窗口");
Container c = jframe.getContentPane(); // 取得窗体的内容面板
jb1 = new JButton("第一个按钮");
jb2 = new JButton("第二个按钮");
jb3 = new JButton("第三个按钮");
jb4 = new JButton("第四个按钮");
jb5 = new JButton("第五个按钮");
c.setLayout(new FlowLayout()); // 设置布局管理器
c.add(jb1);c.add(jb2);c.add(jb3);c.add(jb4);c.add(jb5);
jframe.setSize(350,150);
jframe.setVisible(true);
jframe.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public static void main(String[] args)
{
new FlowLayoutDemo();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -