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

📄 putong.java

📁 这是自己做的图书馆信息管理系统
💻 JAVA
字号:
package infomanagement;

import java.awt.BorderLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.Font;
import com.borland.jbcl.layout.XYLayout;
import java.awt.Color;
import com.borland.dx.dataset.Column;
import javax.swing.JDialog;
import javax.swing.JTextField;
import java.awt.Frame;
import com.borland.dx.sql.dataset.Database;
import com.borland.dx.sql.dataset.QueryDataSet;
import javax.swing.JLabel;
import com.borland.jbcl.layout.XYConstraints;
import javax.swing.JButton;
import java.awt.event.MouseEvent;
import java.awt.Dimension;
import java.awt.Point;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import javax.swing.JPasswordField;
import javax.swing.ImageIcon;

public class putong extends JDialog {
  private JPanel jPanel1 = new JPanel();
  private XYLayout xYLayout1 = new XYLayout();
  private JLabel jLabel1 = new JLabel();
  private JLabel jLabel4 = new JLabel();
  private QueryDataSet queryDataSet1 = new QueryDataSet();
  private Database database1 = new Database();
  private QueryDataSet queryDataSet2 = new QueryDataSet();
  private Column column1 = new Column();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JTextField jTextField1 = new JTextField();
  JLabel jLabel5 = new JLabel();
  JButton jButton1 = new JButton();
  JPasswordField jPasswordField1 = new JPasswordField();
  JLabel jLabel6 ;
  public putong(Frame frame, String title, boolean modal) {
    super(frame, title, modal);
    try {
      jbInit();
      pack();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  public putong() {
    this(null, "", false);
  }
  private void jbInit() throws Exception {
    jPanel1.setLayout(xYLayout1);
    jLabel1.setFont(new java.awt.Font("Dialog", 0, 23));
    jLabel1.setForeground(Color.magenta);
    jLabel1.setBorder(BorderFactory.createEtchedBorder());
    jLabel1.setText("                  普通管理员登陆窗口");
    jLabel4.setBorder(BorderFactory.createEtchedBorder());
    database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor
                            ("jdbc:odbc:local", "sa", "", false,
                             "sun.jdbc.odbc.JdbcOdbcDriver"));
    ImageIcon img = new ImageIcon("D:\\tupian\\2823.gif");
    jLabel6  = new JLabel(img);

    //jPanel1.add(jLabel6, new Integer(Integer.MIN_VALUE));
    jLabel6.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());


    column1.setColumnName("NewColumn1");
    column1.setDataType(com.borland.dx.dataset.Variant.STRING);
    column1.setPreferredOrdinal(0);
    column1.setServerColumnName("NewColumn1");
    column1.setSqlType(0);
    jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
    jLabel2.setForeground(Color.red);
    jLabel2.setText("     请输入您的ID和密码");
    jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
    jLabel3.setForeground(Color.magenta);
    jLabel3.setText("ID");
    jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
    jLabel5.setForeground(Color.magenta);
    jLabel5.setText("密码");
    jButton1.setText("登陆");

    jButton1.addMouseListener(new java.awt.event.MouseAdapter()
    {
      //判断输入是否正确,是就进入,否就弹出一个对话框提示错误
      public void mouseClicked(MouseEvent e){

        abClicked(e);
      }


    }

    ); //jPasswordField1.setText("");

    this.getContentPane().add(jPanel1, BorderLayout.CENTER);
    jPanel1.add(jLabel1, new XYConstraints(0, 1, 399, 53));
    jPanel1.add(jLabel2, new XYConstraints(81, 73, -1, -1));
    jPanel1.add(jLabel3, new XYConstraints(45, 114, -1, -1));
    jPanel1.add(jLabel5, new XYConstraints(47, 148, -1, -1));
    jPanel1.add(jPasswordField1, new XYConstraints(100, 148, 81, 22));
    jPanel1.add(jButton1, new XYConstraints(75, 204, -1, -1));
    jPanel1.add(jLabel6, new XYConstraints(201, 132, 185, 147));
    jPanel1.add(jTextField1, new XYConstraints(101, 114, 79, 21));
    jPanel1.add(jLabel4, new XYConstraints(4, 100, 397, 202));
  }
  void abClicked(MouseEvent e)
  {
      String a=jTextField1.getText();
      String b= jPasswordField1.getText();
      dabaco bb=new dabaco();
      String gg="";
      String hh="";
      boolean mk=false;


      try{

        String query = "select ID,密码 from puguan ";
        ResultSet rs = bb.stmt.executeQuery(query);
        ResultSetMetaData rsmd = rs.getMetaData();
        //System.out.println(rs.getString(1));


        while (rs.next()) {
           gg=rs.getString(1);
           hh=rs.getString(2);
           //System.out.println(gg);
           if(mk==true)
           {

           }
           else if(gg.equals(a)&&hh.equals(b)&&mk==false)
           {
             mk=true;
           }
           else
           {

           }






      }
}
        catch(SQLException ex)
        {

      }


      if(mk==true)
      {
        putong1 dlg=new putong1();
        Dimension dlgSize = dlg.getPreferredSize();
        Dimension frmSize = getSize();
        Point loc = getLocation();
        dlg.setLocation((frmSize.width - dlgSize.width) / 2 +
                     loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
        dlg.setModal(true);
        dlg.pack();

       dlg.setVisible(true);



      }
      else{
        String st="           输入错误,请重新输入";
       cheng dlg = new cheng(st);
       Dimension dlgSize = dlg.getPreferredSize();
       Dimension frmSize = getSize();
       Point loc = getLocation();
       dlg.setLocation( (frmSize.width - dlgSize.width) / 2 +
                       loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
       dlg.setModal(true);
       dlg.pack();

       dlg.setVisible(true);

      }






  }
  void cancel(){
    dispose() ;
  }



}

⌨️ 快捷键说明

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