首页 > 代码库 > Day 4 : QQReg.java

Day 4 : QQReg.java

技术分享

import java.awt.*;
import javax.swing.*;

public class QQReg extends JFrame{
public static void main(String[] args){
QQReg w = new QQReg();
w.setVisible(true);
}
QQReg(){
//设置窗体的基本信息
this.setSize(660 , 380);
this.setLocationRelativeTo(null);
this.setTitle("Talking.GHOUL.Reg");
this.setResizable(false);
this.setIconImage(this.getToolkit().getImage("D:/lab_2/psb (11).jpg"));
//new组件&设置组件
JLabel labTitle = new JLabel(" SIGN UP ");
labTitle.setFont(new Font("", 0, 36));

JLabel labUser = new JLabel(" Username");
labUser.setFont(new Font("", 0, 30));
JLabel labPass = new JLabel(" Password");
labPass.setFont(new Font("", 0, 30));
JLabel labPassRe = new JLabel(" Confirm Password");
labPassRe.setFont(new Font("", 0, 30));

JComboBox cmbUsername = new JComboBox();
cmbUsername.setFont(new Font("", 0, 30));
cmbUsername.addItem("かねき けん");
cmbUsername.addItem("Kaneki Ken");
cmbUsername.addItem("金木 研");

JPasswordField txtPass = new JPasswordField();
txtPass.setFont(new Font("", 0, 25));
JPasswordField txtPassRe = new JPasswordField();
txtPassRe.setFont(new Font("", 0, 25));

JButton btnReg = new JButton(" CONFIRM ");
btnReg.setFont(new Font("", 0, 30));
//布置主面板
JPanel panUser = new JPanel();
panUser.setLayout(new GridLayout(3 , 3));

panUser.add(labUser);
panUser.add(cmbUsername);
panUser.add(labPass);
panUser.add(txtPass);
panUser.add(labPassRe);
panUser.add(txtPassRe);
//布置按钮面板
JPanel panButton = new JPanel();
panButton.setLayout(new FlowLayout());

panButton.add(btnReg);
//布置窗体
this.setLayout(new BorderLayout());

this.add(labTitle , BorderLayout.NORTH);
this.add(panUser , BorderLayout.CENTER);
this.add(panButton , BorderLayout.SOUTH);
}
}

 

Day 4 : QQReg.java