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

📄 admin_frm.java

📁 java数据库编程实例—————————很好很强大第
💻 JAVA
字号:
package train_table;import java.awt.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.awt.event.*;import java.sql.*;import javax.swing.border.*;public class admin_frm extends JFrame {  private JLabel jLabel1 = new JLabel();  private JLabel jLabel2 = new JLabel();  private JButton jButton1 = new JButton();  private JButton jButton2 = new JButton();  private XYLayout xYLayout1 = new XYLayout();  private JPanel jPanel1 = new JPanel();  private XYLayout xYLayout2 = new XYLayout();  private Border border1;  private JPanel jPanel2 = new JPanel();  private XYLayout xYLayout3 = new XYLayout();  private Border border2;  private JPanel jPanel3 = new JPanel();  private Border border3;  private XYLayout xYLayout4 = new XYLayout();  private JLabel jLabel3 = new JLabel();  private JPasswordField password_txt = new JPasswordField();  private JTextField usertxt = new JTextField();  public admin_frm() {    try {      jbInit();      this.setTitle("北京西客站票务系统");    }    catch(Exception e) {      e.printStackTrace();    }  }  private void jbInit() throws Exception {    border1 = BorderFactory.createEmptyBorder();    border2 = BorderFactory.createLineBorder(SystemColor.activeCaption,1);    border3 = BorderFactory.createLineBorder(SystemColor.activeCaption,1);    jLabel1.setText("管理员  :");    this.getContentPane().setLayout(xYLayout1);    jLabel2.setText("密  码    :");    jButton1.setText("确定");    jButton1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton1_actionPerformed(e);      }    });    jButton2.setText("退出");    jButton2.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton2_actionPerformed(e);      }    });    jPanel1.setLayout(xYLayout2);    jPanel1.setBorder(border1);    jPanel2.setLayout(xYLayout3);    jPanel2.setBorder(border2);    jPanel3.setBorder(border3);    jPanel3.setLayout(xYLayout4);    xYLayout1.setWidth(400);    xYLayout1.setHeight(174);    jLabel3.setForeground(Color.red);    jLabel3.setText("联系我们>>>");    jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {      public void mouseExited(MouseEvent e) {        jLabel3_mouseExited(e);      }      public void mouseClicked(MouseEvent e) {        jLabel3_mouseClicked(e);      }    });    jLabel3.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {      public void mouseMoved(MouseEvent e) {        jLabel3_mouseMoved(e);      }    });    usertxt.setText("zheng");    jPanel2.add(jLabel2, new XYConstraints(103, 63, -1, -1));    jPanel2.add(jLabel1, new XYConstraints(103, 33, -1, -1));    jPanel2.add(password_txt,  new XYConstraints(167, 63, 77, 23));    jPanel2.add(usertxt,  new XYConstraints(167, 32, 77, 23));    jPanel1.add(jPanel3,                     new XYConstraints(2, 98, 388, 71));    jPanel3.add(jButton2, new XYConstraints(174, 7, -1, -1));    jPanel3.add(jButton1, new XYConstraints(115, 7, -1, -1));    jPanel3.add(jLabel3,       new XYConstraints(305, 40, -1, -1));    jPanel1.add(jPanel2,               new XYConstraints(2, 0, 388, 100));    this.getContentPane().add(jPanel1,     new XYConstraints(4, 2, 390, 296));    pack();  }  void jButton1_actionPerformed(ActionEvent e) {    errormessage errmsg=new errormessage();       //错误处理    ResultSet rs=null;                            //定义结果集rs,存放结果集    dbBean db=new dbBean();                       //实例化dbBean用于查询    String user=usertxt.getText();    String password=password_txt.getText();    //sql查询语句,用于核查用户和密码    String sql="select * from administartor where admini='"+user+"' and password='"+password+"'";    //检查输入是否为空    if(!errmsg.isEmpty(user)&&!errmsg.isEmpty(password))    {      try{           rs=db.executeQuery(sql);   //执行查询           if(rs.next())              //判断结果集是否存在           {             GetFrmLocation gfl=new GetFrmLocation();//实例化GetFrmLocatin             mainfrm frame=new mainfrm();            //实例化下一个frame             gfl.get_location(frame);                //让frame显示在屏幕中心             frame.show();                          //frame的显示             this.dispose();                        //本窗体的退出            }         else{              //错误提示             JOptionPane.showMessageDialog(null, "对不起,您不是合法用户!");            }       }catch(SQLException ex)            {          System.err.println("sql error!");             }      }      else{          JOptionPane.showMessageDialog(null, "输入不能为空清输入合理数据!");         }    }  void jButton2_actionPerformed(ActionEvent e) {      System.exit(0);     //退出系统  }  void jLabel3_mouseMoved(MouseEvent e) {     //鼠标经过事件    jLabel3.setForeground(Color.blue);        //jLabel3文字为蓝色                          //获得鼠标形状,为手型    setCursor((Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)));  }  void jLabel3_mouseExited(MouseEvent e) {      //鼠标退出事件     jLabel3.setForeground(Color.red);         //jLabel3文字为红色                         //获得鼠标形状,为默认值     setCursor((Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)));  }  void jLabel3_mouseClicked(MouseEvent e) {    jianjie frame =new jianjie();          //显示下一个frame    GetFrmLocation zhongxin=new GetFrmLocation();    zhongxin.get_location(frame);        //将frame显示在屏幕中心    frame.show(); }}

⌨️ 快捷键说明

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