java代码实现qq界面 java仿登录界面简洁( 四 )


this.setBounds(200,200,270,250);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
19、//实现动作监听器接口中的方法actionPerformed
public void actionPerformed(ActionEvent e)
{
20、//如果事件源为文本框
if(e.getSource()==jName)
{
21、//切换输入焦点到密码框
jPassword.requestFocus();
}
22、//如果事件源为重置按扭
else if(e.getSource()==jb[1])
{
23、//清空姓名文本框、密码框和show标签中的所有信息
jl[2].setText("");
jName.setText("");
jPassword.setText("");
24、//让输入焦点回到文本框
jName.requestFocus();
}
25、//如果事件源为登陆按钮,则判断登录名和密码是否正确
else
{
26、//判断用户名和密码是否匹配
if(jName.getText().equals("lixiangguo")
String.valueOf(jPassword.getPassword()).equals("19801001"))
{
27、jl[2].setText("登陆成功 , 欢迎您的到来!");
}
else
{
28、jl[2].setText("对不起,您的用户名或密码错误!");
}
【java代码实现qq界面 java仿登录界面简洁】}
}
public static void main(String[] args)
{
29、//创建LoginTest窗体对象
new LoginTest();
}
}
求QQ登陆界面的Java GUI(图形用户界面开发)代码!import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Demo extends JFrame{
Container contentPane;
ImageIcon img = new ImageIcon("002.jpg");
JPanel paneTop = new JPanel();
JPanel paneMid = new JPanel();
JPanel paneBut = new JPanel();
JPanel paneAll = new JPanel();
JLabel lblTop = new JLabel();
JLabel lblName = new JLabel();
JLabel lblPwd = new JLabel();
JLabel lblApply = new JLabel();
JLabel lblForget = new JLabel();
JLabel lblModel = new JLabel();
JLabel lblNull = new JLabel();
JTextField txtName = new JTextField(15);
JPasswordField txtPwd = new JPasswordField(15);
JComboBox cmb = new JComboBox();
JCheckBox chk = new JCheckBox();
JButton btnKill = new JButton("查杀木马");
JButton btnSet = new JButton("设置");
JButton btnLogin = new JButton("登录");
Demo(){
lblTop.setIcon(img);
paneTop.add(lblTop);
lblName.setText("QQ帐号:");
lblApply.setText("申请帐号");
lblPwd.setText("QQ密码:");
lblForget.setText("忘记密码?");
lblModel.setText("状态:");
String[] s1 = {"隐身","在线","忙碌"};
cmb.addItem(s1[0]);
cmb.addItem(s1[1]);
cmb.addItem(s1[2]);
chk.setText("自动登录");
paneMid.add(lblName);
paneMid.add(txtName);
paneMid.add(lblApply);
paneMid.add(lblPwd);
paneMid.add(txtPwd);
paneMid.add(lblForget);
paneMid.add(lblModel);
paneMid.add(cmb);
paneMid.add(chk);
paneBut.add(btnKill);
paneBut.add(btnSet);
paneBut.add(btnLogin);
contentPane = this.getContentPane();
contentPane.add(paneTop,BorderLayout.NORTH);
contentPane.add(paneMid,BorderLayout.CENTER);
contentPane.add(paneBut,BorderLayout.SOUTH);
setTitle("欢迎使用QQ");
setSize(330,240);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screen.width - getSize().width)/2,(screen.height - getSize().height)/2 );
setVisible(true);

推荐阅读