总结:主要是如何布局。还是存在很大问题
package clientFrame; import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.JPasswordField; public class see extends JFrame { // 做一个登陆的密码,账户框。2个h文本框,2个label JLabel jl1, jl2; JButton jb; JPasswordField pf; JTextField tf1, tf2; public see() { jl1 = new JLabel("用户名:"); jb = new JButton("登 陆"); jl2 = new JLabel("密 码:"); tf1 = new JTextField(10); pf = new JPasswordField(10); tf2 = new JTextField(10); this.setVisible(true); this.setLayout(new FlowLayout()); this.add(jl1); this.add(tf1); this.add(jl2); this.add(pf); // this.add(tf2); this.add(jb); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(200, 200); } public static void main(String[] args) { see s = new see(); } }