标签:display default 使用 button textfield new jbutton visible ack
代码如下:
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
}
}
标签:display default 使用 button textfield new jbutton visible ack
原文地址:http://www.cnblogs.com/F001li/p/7055942.html