- import java.awt.FlowLayout;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- public class Ch105 {
- JFrame fm;
- JButton btn1, btn2, btn3, btn4, btn5, btn6;
- Ch105()
- {
- btn1 = new JButton("xxx");
- btn2 = new JButton("xxxxxxx");
- btn3 = new JButton("xxxxxxxxxx");
- btn4 = new JButton("xxxxxxxxx xxxxxxx");
- btn5 = new JButton("xxx");
- btn6 = new JButton("x");
-
- fm = new JFrame("JPanel");
- fm.setBounds(100, 100, 580, 435);
- fm.setVisible(true);
- fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- fm.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 15));
- 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 Ch105();
- }
- }
複製代碼 |