使用java语言编写窗口按钮

代码如下:

package Day08; import java.awt.FlowLayout; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField; public class ShowFlowLayout extends JFrame {
 public ShowFlowLayout() {
 //Set FlowLayout, hgap = 10, vgap = 20, alignment = LEFT
 FlowLayout myFlowLayout = new FlowLayout(FlowLayout.LEFT, 10, 20);
 setLayout(myFlowLayout);

 add(new JLabel("姓名1"));
 add(new JTextField(8));
 add(new JLabel("姓名2"));
 add(new JTextField(8));
 add(new JLabel("姓名3"));
 add(new JTextField(8));
 }

 public static void main(String[] args) {
 ShowFlowLayout frame = new ShowFlowLayout(); 

 frame.setSize(350, 200);//set the frame size
 frame.setLocationRelativeTo(null);// center a frame
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// center a frame
 frame.setVisible(true);//display the frame
 }
}