//登录界面packagecom.gui;importjava.sql.*;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.util.List;importcom.DateSystem.*;publicclassLandingextendsJFrameimplementsActionListener{//声明创建组建JLabellbl_name,lbl_password;JTextFieldtext_name;JPasswordFieldpassword;JCheckBoxbox_rember,box_auto;JButtonbutton_submit,button_zhuce;JPaneljPanel;privateImageIconbackground;//背景图片publicLanding(){super(用户登录);lbl_name=newJLabel(用户名:);lbl_password=newJLabel(密码:);text_name=newJTextField(,30);password=newJPasswordField();button_submit=newJButton(登录);button_zhuce=newJButton(注册);jPanel=newJPanel();box_rember=newJCheckBox(记住密码);box_auto=newJCheckBox(自动登录);background=newImageIcon(g:\\java\\BaoDing_Shoop\\img\\bg2.jpg);//背景图片G:\java\BaoDing_Shoop\src\com\guiJLabellabel=newJLabel(background);//把背景图片显示在一个标签里面//把标签的大小位置设置为图片刚好填充整个面板label.setBounds(0,0,background.getIconWidth(),background.getIconHeight());//把内容窗格转化为JPanel,否则不能用方法setOpaque()来使内容窗格透明try{//jPanel=(JPanel)this.getContentPane();}catch(IllegalArgumentExceptionie){System.out.print(你啊哈);}jPanel.setOpaque(false);Fontfont=newFont(Serif,Font.BOLD,20);lbl_name.setFont(font);lbl_password.setFont(font);this.getLayeredPane().setLayout(null);//把背景图片添加到分层窗格的最底层作为背景this.getLayeredPane().add(label,newInteger(Integer.MIN_VALUE));this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setSize(400,300);this.setLocationRelativeTo(null);this.setVisible(true);this.setResizable(false);jPanel.setLayout(null);lbl_name.setBounds(50,30,150,50);lbl_password.setBounds(50,90,150,50);text_name.setBounds(120,45,200,25);password.setBounds(120,105,200,25);box_rember.setBounds(120,155,100,20);box_auto.setBounds(220,155,100,20);button_submit.setBounds(100,200,60,30);button_zhuce.setBounds(240,200,60,30);jPanel.add(button_submit);jPanel.add(button_zhuce);jPanel.add(lbl_name);jPanel.add(lbl_password);jPanel.add(text_name);jPanel.add(password);//jPanel.add(box_rember);//jPanel.add(box_auto);add(jPanel);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});//注册监听button_submit.addActionListener(this);button_zhuce.addActionListener(this);text_name.addActionListener(this);password.addActionListener(this);//box_auto.addActionListener(this);//box_rember.addActionListener(this);}publicstaticvoidmain(String[]args){Landinglanding=newLanding();}@OverridepublicvoidactionPerformed(ActionEvente){//TODOAuto-generatedmethodstubStringbuttString=e.getActionCommand();//返回按钮值Booleanflag_remeber=box_rember.isSelected();//判断记住密码是否被选中Booleanflag_auto=box_auto.isSelected();if(buttString.equals(登录)){System.out.println(登录);Stringname=text_name.getText().trim();Stringpass=String.valueOf(password.getPassword());Stringsql=select*fromuserdatawhereusername='+name+'anduserpassword='+pass+';Userdateuda=newUserdate();ListUserlist=uda.findUser(sql);if(list.size()0){JOptionPane.showMessageDialog(this,name+,欢迎登陆!);MainmGui=newMain();mGui.setVisible(true);this.dispose();}else{JOptionPane.showMessageDialog(this,无法登录,请重新输入用户名和密码);this.text_name.setText();this.password.setText();}if(box_rember.isSelected()){System.out.println(记住密码);}else{System.out.println(没有记住密码);}if(box_auto.isSelected()){System.out.println(自动登录);}else{System.out.println(没有自动登录);}}else{System.out.println(注册);Registerregister=newRegister();register.setSize(600,470);register.setLocationRelativeTo(null);register.setVisible(true);register.setResizable(false);}}}