- import java.awt.FlowLayout;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- public class Ch01 {
- JFrame fm;
- JButton btn1,btn2,btn3,btn4,btn5,btn6;
- Ch01()
- {
- btn1=new JButton("xxx");
- btn2=new JButton("xxxxxxx");
- btn3=new JButton("xxxxxxxxxxx");
- btn4=new JButton("xxxxxxxxx xxxxxxx");
- btn5=new JButton("xxx");
- btn6=new JButton("x");
- fm=new JFrame("FlowLayout");
- fm.setBounds(100, 100, 580, 435);
- fm.setVisible(true);
- fm.setLayout(new FlowLayout(FlowLayout.LEFT,5,10));
- fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- fm.add(btn1);
- fm.add(btn2);
- fm.add(btn3);
- fm.add(btn4);
- fm.add(btn5);
- fm.add(btn6);
- }
- public static void main(String[] args) {
- new Ch01();
- }
- }
複製代碼 |