⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginframe.java

📁 酒店管理系统·可用于一般旅社的营业操作。方便你的酒店管理
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.redingsoft.login;import com.redingsoft.locationutil.LocationUtil;import com.redingsoft.mainframe.HotelFrame;import com.redingsoft.sql.SetSQL;import com.redingsoft.sunsdk.swing.OJButton;import com.redingsoft.sunsdk.swing.setimage;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Dimension;import java.awt.FlowLayout;import java.awt.Font;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.ResultSet;import javax.swing.*; public class LoginFrame extends JFrame implements ActionListener{      //声明标签    JLabel jl1,jl2,jl3,warnjl;    //声明一个文本框    JTextField tf1;    JPasswordField tf2;    //声明2个按钮    JButton bt1,bt2;    //声明面板    JPanel jp0,jp1,jp2,jp3,mainpane;    //声明一个整数来计算登录次数  private  int count=0;    private JPanel jp4;  public   LoginFrame (){  //实例化标签    //  jl1=new JLabel("用户登陆");      jl1=new JLabel("用户名:");      jl2=new JLabel("   密 码:");      warnjl=new JLabel("");     //修饰警告标签      warnjl.setForeground(Color.RED);      warnjl.setFont(new Font("宋体",Font.BOLD,14));      //实例化文本框      tf1=new JTextField(16);      tf2=new JPasswordField(16);      //按钮      bt1=new OJButton("com/redingsoft/pic/u02.gif","登录","登陆",true);      bt2=new OJButton("com/redingsoft/pic/exit.gif","退出","退出",true);    //实例化面板      jp0=new setimage("com/redingsoft/pic/wel_1.gif");      jp1=new JPanel ();      jp2=new JPanel ();      jp3=new JPanel ();      jp4=new JPanel();      mainpane=new JPanel(new FlowLayout(FlowLayout.LEADING,10,1));      //添加组      jp1.add(jl1);      jp1.add(tf1);      jp2.add(jl2);      jp2.add(tf2);      jp3.add(bt1);      jp3.add(bt2);      jp4.add(warnjl);      /////////////////      mainpane.add(jp1);      mainpane.add(jp2);      mainpane.add(jp3);      mainpane.add(jp4);      ///////////      jp3.setPreferredSize(new Dimension(300,40));      jp0.setPreferredSize(new Dimension(300,150));      mainpane.setPreferredSize(new Dimension(300,180));      /////////////////      //添加侦听      bt1.addActionListener(this);      bt2.addActionListener(this);      this.add(BorderLayout.NORTH,jp0);      this.add(BorderLayout.CENTER,mainpane);      this.setSize(310,350);      this.setDefaultCloseOperation(LoginFrame.EXIT_ON_CLOSE);      this.setTitle("红软酒店管理登录");      LocationUtil.setLocation(this);      this.setResizable(false);      this.setVisible(true);           }  public static void main(String []aa){  //快闪窗口    startWindow my=new startWindow();      //主窗口  new LoginFrame ();  }    public void actionPerformed(ActionEvent e) {     //   throw new UnsupportedOperationException("Not supported yet.");        Object o=e.getSource();        String id = tf1.getText().trim();        String pwd="";        char[] pwd1 = tf2.getPassword();      int i=  pwd1.length-1;      int m=0;       while(m<=i){           String str=pwd1[m]+"";            pwd+=str;            m++;          }      // System.out.print(pwd);        String sql="select userid,pwd from pwd where delmark=0";        if(o==bt1){          try{      ResultSet rs =SetSQL.executeQuery(sql);      count++;            while(rs.next()){              if(id.equals(rs.getString(1))&&pwd.equals(rs.getString(2))){                  rs.close();                 new HotelFrame();                 this.dispose();                              }else{                            if(count==3){                JOptionPane.showMessageDialog(null, "<html><body><font color=red size=4>你的输入已经超过3次。<br>系统退出。。。</body></html>");                 System.exit(0);              }else{                             warnjl.setText("<html><body>户名或密码错误!<br><font color=blue>你已经输入【"+count+"】次了,超过</font>【3】<font color=blue>次,<br>系统将会退出。</font></body></html>");              }                            }              //end if(id.equals(rs.getString(1))&&id.equals(rs.getString(2)))            }          }catch(Exception ex){       //   ex.printStackTrace();          } //end try                 }//end fi(o==bt1)        if(o==bt2){      int flag=  JOptionPane.showConfirmDialog(null, "确认退出吗?", "提示", JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);         if(flag==JOptionPane.OK_OPTION){         System.exit(0);         }           }    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -