资源描述:
《java--登陆注册系统(模仿qq登陆界面)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Java--登陆注册系统(数据库)importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;publicclassDengLuextendsJFrameimplementsActionListener,KeyListener,ItemListener,FocusListener{JLabeltop,bott;JComboBoxcombobox;JPasswordFieldpassword;JButtonb_login,b_re
2、gedit;JPanelpanelMain,panel_center;publicDengLu(){super("登陆系统");panelMain=newJPanel(newBorderLayout(10,10)){publicvoidpaintComponent(Graphicsg){Graphics2Dg2=(Graphics2D)g;super.paintComponent(g);Imageimg=Toolkit.getDefaultToolkit().getImage("G:\image\Denglubg.j
3、pg");g2.drawImage(img,0,0,this.getWidth(),this.getHeight(),this);}};top=newJLabel();top.setPreferredSize(newDimension(this.getWidth(),30));bott=newJLabel();bott.setForeground(Color.white);bott.setPreferredSize(newDimension(this.getWidth(),25));centerBuild();addit
4、em();panelMain.add(top,BorderLayout.NORTH);panelMain.add(bott,BorderLayout.SOUTH);panelMain.add(panel_center,BorderLayout.CENTER);combobox.addItemListener(this);password.addActionListener(this);b_login.addActionListener(this);b_regedit.addActionListener(this);com
5、bobox.addFocusListener(this);password.addFocusListener(this);b_login.addFocusListener(this);b_regedit.addFocusListener(this);combobox.addKeyListener(this);password.addKeyListener(this);this.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEventw
6、e){quit();}});this.setContentPane(panelMain);//设置窗口面板this.setSize(350,235);Dimensionfrm=this.getSize();Dimensionscr=Toolkit.getDefaultToolkit().getScreenSize();this.setLocation((scr.width-frm.width)/2,(scr.height-frm.height)/2);this.setResizable(false);//设置窗口不可放大
7、缩小this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);//sunswing.setWindowCenter(this);this.setVisible(true);//password.requestFocus(true);//设置焦点给密码框}privatevoidcenterBuild(){JLabelL1,L2;panel_center=newJPanel(null);panel_center.setOpaque(false);L1=newJLabe
8、l("用户名:");L1.setForeground(Color.white);L2=newJLabel("登录密码:");L2.setForeground(Color.white);b_login=newJButton("登陆");b_regedit=newJButton("注册");combobox=newJCo