//代码如下:
******************************************************
//ButtonTest.java
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class ButtonTest extends JFrame {
public ButtonTest() {
this.setLayout(new FlowLayout());
for (int i = 1; i <= 11; i++) {
this.add(new JButton("button" + i));
}
this.setBounds(200, 100, 300, 200);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
ButtonTest bt = new ButtonTest();
}
}
******************************************************
运行界面如下: