代码如下[Java] 纯文本查看 复制代码 package sy1.GUI;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class LoginFrame extends JFrame {
public static void main(String[] args) {
new LoginFrame();
}
private JPanel jp1, jp2, jp3;
private JLabel jlb1, jlb2;
private JButton login_jb,regist_jb, reset_jb;
private JTextField jtf1;
private JPasswordField jpf1;
public LoginFrame(){
initComponents();
init();
}
private void init(){
this.setSize(400,200);
this.setVisible(true);
this.setTitle("登录界面");
}
public void initComponents() {
jp1 = new JPanel();
jp2 = new JPanel();
jp3 = new JPanel();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
jlb1 = new JLabel("用户名");
jlb2 = new JLabel("密 码");
login_jb = new JButton("登录");
login_jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
}
});
reset_jb = new JButton("重置");
jtf1 = new JTextField(10);
jpf1 = new JPasswordField(10);
this.setLayout(new FlowLayout(FlowLayout.LEFT,40,80));
jp1.add(jlb1);
jp1.add(jtf1);
jp2.add(jlb2);
jp2.add(jpf1);
jp3.add(login_jb);
jp3.add(regist_jb);
jp3.add(reset_jb);
// 加入到JFrame
this.add(jp1);
this.add(jp2);
this.add(jp3);
}
}
|