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

📄 operatepasswordgui.java

📁 图书管理系统。 借书
💻 JAVA
字号:
package GUI;


import shujuku.*;

import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;



public class OperatePasswordGUI extends JFrame implements ActionListener
{
	 /* public void actionPerformed(ActionEvent e)
	  {
	   if(e.getActionCommand().equals("取消"))
	   {
	    dispose();
	   }
	   else if(e.getActionCommand().equals("确定"))
	   {
	    SystemOperateGUI ggg=new SystemOperateGUI();
	    dispose();
	   }
	  }*/
	JTextField a1=new JTextField(15);
    JTextField a2=new JTextField(15); JPasswordField te2;
    JTextField a3=new JTextField(15); JPasswordField te3;
    JTextField a4=new JTextField(15);
    JTextField a5=new JTextField(15);
    JTextField a6=new JTextField(15);
		 public void actionPerformed(ActionEvent e){
			 String com=e.getActionCommand();
			 if(com.equals("取消")){
				 GUIClass go=new GUIClass();
				 go.setVisible(true);
				 show();
				 dispose();
			 }
			 else if(com.equals("确定")){
				String a=a1.getText();//System.out.println(a);
				 String b=te2.getText();//System.out.println(b);
				 try{
					 Connection con=LinkToDB.buildlinktodb();
						Statement state = con.createStatement();
						ResultSet result = state
								.executeQuery("SELECT Password FROM 管理员 WHERE WorkerId='"+a+"'");
						
							while (result.next()){String x = result.getString("Password");//System.out.println(x);
								if(x.equals(b)){
			    			SystemOperateGUI go=new SystemOperateGUI();
			   			 go.setVisible(true);
			   			 show();
			   			 dispose();}
			    		else
			    			a1.setText("密码错误");}
			    		result.close();
			    		state.close();
			    		con.close();
			    	}
			    	catch(Exception f){
			    		System.out.println(f);
			    		System.out.println("错误");}}
			    	}
	  public OperatePasswordGUI()
	  {
	   setSize(500,300);
	   setTitle("操作");
	   Dimension screen = getToolkit().getScreenSize();  //得到屏幕尺寸
	    setLocation((screen.width-getSize().width)/2,(screen.height-getSize().height)/2); //设置窗口位置
	   Container con=getContentPane();
	   con.setLayout(new GridLayout(3,1));
	   JLabel l1=new JLabel("操作员号码",JLabel.CENTER);
	   JLabel l2=new JLabel("操作员口令",JLabel.CENTER);
	   JPanel p1=new JPanel();p1.setBackground(Color.LIGHT_GRAY);
	   JPanel p2=new JPanel();p2.setBackground(Color.LIGHT_GRAY);
	  te2=new JPasswordField(15); te2.setEchoChar('*');
	   p1.add(l1);p1.add(a1);
	   p2.add(l2);p2.add(te2);
	   JPanel b=new JPanel();b.setBackground(Color.LIGHT_GRAY);
	   JButton b1=new JButton("确定");
	   b1.addActionListener(this);
	   b.add(b1);
	   JButton b2=new JButton("取消");
	   b2.addActionListener(this);
	   b.add(b2);
	   con.add(p1);con.add(p2);con.add(b);
	   setVisible(true);
	  }
	 
private class WindowDestroyer extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
 WindowConfirm gui=new WindowConfirm();
}
} public static void main(String args[])
{
	OperatePasswordGUI gui=new  OperatePasswordGUI();
 gui.setVisible(true);
}}

⌨️ 快捷键说明

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