标签:pass str als images frame alt title login end
import java.awt.*;
import javax.swing.*;
public class QQLogin extends JFrame{
QQLogin(){
this.setSize(300 , 400);
//new 组件
JLabel labUser = new JLabel(" Username");
JLabel labPass = new JLabel(" Password");
JTextField txtUser = new JTextField();
JPasswordField txtPass = new JPasswordField();
JButton btnLogin = new JButton("Sign in");
JButton btnReg = new JButton("Sign up");
JButton btnCancel = new JButton("Cancel");
//布置输入面板
JPanel panInput = new JPanel();
panInput.setLayout(new GridLayout(2 , 2));
panInput.add(labUser);
panInput.add(txtUser);
panInput.add(labPass);
panInput.add(txtPass);
//布置按钮面板
JPanel panButton = new JPanel();
panButton.setLayout(new FlowLayout());
panButton.add(btnLogin);
panButton.add(btnReg);
panButton.add(btnCancel);
//布置窗体
this.setLayout(new BorderLayout());
this.add(panInput , BorderLayout.CENTER);
this.add(panButton , BorderLayout.SOUTH);
//装饰窗体
this.setLocationRelativeTo(null);
this.setSize(440 , 165);
this.setTitle("Tokyo.GHOUL");
this.setResizable(false);
//设置窗体LOGO
this.setIconImage(this.getToolkit().getImage("D:/lab_2/psb (11).jpg"));
}
public static void main(String[] args){
QQLogin w = new QQLogin();
w.setVisible(true);
}
}
标签:pass str als images frame alt title login end
原文地址:http://www.cnblogs.com/xkxf/p/5989127.html