第一部分的

ADDBOOK

package Testv1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Calendar;
import java.awt.event.ActionEvent;
import java.awt.Color;

public class AddBook extends JFrame {//JFrame是Java语言中用于创建GUI(图形用户界面)
	// 应用程序的类。
//JPanel是Java语言中的一个面板类,
// 也属于Swing组件库的一部分,
// 用于创建GUI应用程序的用户界面上的一个空间。
// JPanel通常被用作JFrame容器中的一个子组件,
// 具有可视化和布局管理的功能,
// 可以在其内部添加其他的Swing组件,
// 例如按钮、文本框、标签、列表等等。
//
//contentPane是Java Swing窗体类(如JFrame)的一个组件,
// 它是窗体的内容面板。在Java Swing中,窗体的内容通常在contentPane中显示,
// 而不是直接将组件添加到窗体上。
//在默认情况下,Swing窗体类(如JFrame、JDialog等)是没有内容面板的,
// 需要通过调用getContentPane()方法获取它,并将组件添加到其中。
// contentPane是一个JPanel,其默认的布局管理器是BorderLayout,
// 但也可以设置其他的布局管理器,从而控制其中所包含的组件的位置和尺寸。
// 通过控制contentPane的布局管理器,可以实现非常灵活的用户界面。
	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	private JTextField textField_4;
	private JTextField textField_5;
	private JTextField textField_6;
	private JTextField textField_7;
//这段代码定义了一个AddBook类,继承自JFrame类,并创建了一个JPanel对象contentPane。
// 在contentPane上添加了8个文本框,用于输入图书的基本信息,如书名、作者、出版社等。
// 其中,JTextField是Swing组件库中的文本框控件,用于显示和接受用户输入。
// 通过调用JTextField类的构造方法,可以创建一个文本框对象,
// 需要传入该文本框的初始显示文本和长度等信息。这些文本框用于接受用户输入的图书信息,
// 供后续添加操作使用。
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					AddBook frame = new AddBook();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
//这段代码定义了一个main方法作为程序入口,首先调用了EventQueue类中的invokeLater方法,
// 创建了一个新的线程并调用runnable对象,在该线程中创建了一个AddBook对象,
// 并调用setVisible()方法将该对象设置为可见的,即显示在屏幕上。
// 在该try-catch块中如果出现异常,将调用printStackTrace()方法打印异常信息。
// 这段代码使程序能够启动并展示AddBook窗口。
	/**
	 * Create the frame.
	 */
	public AddBook() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 360);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("\u6DFB\u52A0\u56FE\u4E66");
		lblNewLabel.setFont(new Font("����", Font.PLAIN, 20));
		lblNewLabel.setBounds(170, 10, 92, 38);
		contentPane.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("\u4E66\u53F7");
		lblNewLabel_1.setBounds(32, 48, 54, 15);
		contentPane.add(lblNewLabel_1);
		
		textField = new JTextField();
		textField.setBounds(71, 45, 148, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JLabel lblNewLabel_2 = new JLabel("\u4E66\u540D");
		lblNewLabel_2.setBounds(32, 80, 54, 15);
		contentPane.add(lblNewLabel_2);
//这段代码是AddBook类的构造方法,用于初始化窗口。
// 其中,setDefaultCloseOperation方法设置窗口关闭时默认的操作(在本例中为退出程序),
// setBounds方法设置窗口的起始位置和大小。
// contentPane是窗口的内容面板,在内容面板上添加了一个JLabel对象和7个JTextfield对象,
// 用于输入图书信息。其中,JLabel是Swing组件库中的标签控件,
// 用于显示文本或图像。同样,通过调用JLabel类的构造方法,
// 可以创建一个标签对象,并设置其显示的文本、字体、颜色等属性。
// JTextfield对象与上面的解释一致。setText()方法可设置文本框中的初始字符串,
// setColumns()方法可设置文本框的长度。
// 通过setLayout()方法将内容面板的布局设为null(即不使用任何布局管理器),
// 可以更加灵活地控制各个组件的位置和大小。
		textField_1 = new JTextField();
		textField_1.setBounds(71, 77, 242, 21);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		JLabel lblNewLabel_3 = new JLabel("\u4F5C\u8005");
		lblNewLabel_3.setBounds(32, 113, 54, 15);
		contentPane.add(lblNewLabel_3);
		
		textField_2 = new JTextField();
		textField_2.setBounds(71, 110, 242, 21);
		contentPane.add(textField_2);
		textField_2.setColumns(10);
		
		JLabel lblNewLabel_4 = new JLabel("\u51FA\u7248\u793E");
		lblNewLabel_4.setBounds(32, 144, 54, 15);
		contentPane.add(lblNewLabel_4);
		
		JLabel lblNewLabel_5 = new JLabel("\u5B9A\u4EF7");
		lblNewLabel_5.setBounds(32, 172, 54, 15);
		contentPane.add(lblNewLabel_5);
		
		textField_3 = new JTextField();
		textField_3.setBounds(71, 141, 242, 21);
		contentPane.add(textField_3);
		textField_3.setColumns(10);
		
		textField_4 = new JTextField();
		textField_4.setBounds(71, 169, 242, 21);
		contentPane.add(textField_4);
		textField_4.setColumns(10);
		
		JLabel lblNewLabel_6 = new JLabel("\u5185\u5BB9\u7B80\u4ECB");
		lblNewLabel_6.setBounds(17, 197, 54, 15);
		contentPane.add(lblNewLabel_6);
		
		textField_5 = new JTextField();
		textField_5.setBounds(71, 194, 242, 21);
		contentPane.add(textField_5);
		textField_5.setColumns(10);
		
		JLabel lblNewLabel_7 = new JLabel("\u72B6\u6001");
		lblNewLabel_7.setBounds(32, 225, 54, 15);
		contentPane.add(lblNewLabel_7);
		
		textField_6 = new JTextField();
		textField_6.setBounds(71, 222, 242, 21);
		contentPane.add(textField_6);
		textField_6.setColumns(10);
		
		textField_7 = new JTextField();
		textField_7.setBounds(71, 250, 242, 21);
		contentPane.add(textField_7);
		textField_7.setColumns(10);
		
		JLabel lblNewLabel_9 = new JLabel("\u64CD\u4F5C\u6210\u529F");
		lblNewLabel_9.setBounds(137, 281, 54, 15);
		contentPane.add(lblNewLabel_9);
		lblNewLabel_9.setVisible(false);
		
		JLabel lblNewLabel_10 = new JLabel("\u64CD\u4F5C\u5931\u8D25");
		lblNewLabel_10.setForeground(Color.RED);
		lblNewLabel_10.setBounds(135, 296, 54, 15);
		contentPane.add(lblNewLabel_10);
		lblNewLabel_10.setVisible(false);
//这段代码是用Java Swing编写一个窗口应用程序的界面布局,
// 包含了几个文本框和标签用于输入和显示一个出版物的信息,
// 如标题、作者、出版社、价格、内容简介和状态等。
// 同时也包含了两个标签,用于在操作成功或失败时显示给用户。
// 其中,setVisible(false)用于在运行时默认情况下将标签隐藏,直到操作成功或失败时才显示。
		JButton btnNewButton = new JButton("\u786E\u8BA4");
		btnNewButton.addActionListener(new ActionListener() {//ȷ��
			public void actionPerformed(ActionEvent e) {
				String num = new String(textField.getText());
				String name = new String(textField_1.getText());
				String writer = new String(textField_2.getText());
				String publish = new String(textField_3.getText());
				String price = new String(textField_4.getText());
				String intro = new String(textField_5.getText());
				String status = new String(textField_6.getText());
				String cla = new String(textField_7.getText());
				
				if(num.equals("") || name.equals("") || writer.equals("") || publish.equals("") || price.equals("")||intro.equals("") ||status.equals("") || cla.equals("")) {
					lblNewLabel_10.setVisible(true);
				}
				else {
				String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=LibraryManagement";
				String userName="sa";
				String userPwd="QWEASDZXC000000";
				Connection dbConn = null;
//这段代码用于实现一个“确定”按钮的功能,当用户点击该按钮时,
// 程序会从文本框中获取用户输入的数据,并利用JDBC API连接数据库,将输入的数据保存到数据库中。
// 如果所有的文本框中都有输入数据,那么标签lblNewLabel_10将会被隐藏;
// 否则,该标签将会显示给用户。
// 其中,dbURL、userName和userPwd用于定义数据库的访问路径、用户名和密码,
// dbConn用于保存数据库的连接对象。
				try {
					Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
					dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
					
					PreparedStatement pst = null;
					pst = dbConn.prepareStatement("insert into ͼ�� values(?,?,?,?,?,?,?,?)");
					pst.setString(1, num);//���
					pst.setString(2, name);//����
					pst.setString(3, writer);//����
					pst.setString(4, publish);//������
					pst.setString(5, price);//����
					pst.setString(6, intro);//���ݼ��
					pst.setString(7, status);//״̬
					pst.setString(8, cla);//����
					pst.addBatch();
					pst.executeBatch();
						
					dbConn.close();
					lblNewLabel_9.setVisible(true);
					
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
					lblNewLabel_10.setVisible(true);
				} catch (ClassNotFoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
					lblNewLabel_10.setVisible(true);
				}
				
				}
				if(lblNewLabel_9.isVisible())
					lblNewLabel_10.setVisible(false);
			}
		});
		btnNewButton.setBounds(32, 275, 93, 23);
		contentPane.add(btnNewButton);
//这段代码在按钮的监听器中,定义了JDBC API的相关操作,包括向数据库中插入数据。
// 首先,程序利用Class.forName()方法加载SQL Server数据库的驱动程序,
// 然后通过DriverManager.getConnection()方法连接数据库。
// 接下来,程序定义PreparedStatement对象pst,
// 并利用setString()方法将输入的数据绑定到SQL语句的参数中。
// 最后,程序执行pst.executeBatch()方法,向数据库中插入数据,
// 并通过setVisible()方法将标签lblNewLabel_9设置为可见状态,表示操作成功。
// 如果发生异常,程序将会通过setVisible()方法将标签lblNewLabel_10设置为可见状态,
// 表示操作失败。其中,pst.addBatch()方法将预定义命令添加到命令列表中,
// pst.executeBatch()方法将命令列表中的所有预定义命令执行一次。
// 如果lblNewLabel_9标签可见,那么lblNewLabel_10标签将被隐藏。
		JButton btnNewButton_1 = new JButton("\u8FD4\u56DE");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});
		btnNewButton_1.setBounds(308, 275, 93, 23);
		contentPane.add(btnNewButton_1);
		
		JLabel lblNewLabel_8 = new JLabel("\u5206\u7C7B");
		lblNewLabel_8.setBounds(32, 250, 54, 15);
		contentPane.add(lblNewLabel_8);
		
	}

}
//这段代码创建了一个名为btnNewButton_1的JButton对象,
// 用于在用户完成输入和保存操作后退出程序。
// 当用户单击该按钮时,程序会通过setVisible(false)方法将整个窗口设为不可见状态。
// 同时,该代码还创建了一个名为lblNewLabel_8的JLabel对象,
// 用于显示“分类”这个文本标签。整个代码段表示了一个完整的窗口应用程序界面,
// 包括文本框、标签和按钮等组件,实现了图书信息的输入和保存,以及窗口关闭的功能。

BOOKFIND

package Testv1;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.awt.event.ActionEvent;
import javax.swing.JComboBox;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;

public class BookFind extends JFrame {

	private JPanel contentPane;
	private JTextField textField_2;
	private JTextField textField_3;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BookFind frame = new BookFind();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public BookFind() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 581, 391);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		textField_2 = new JTextField();
		textField_2.setBounds(23, 7, 139, 21);
		contentPane.add(textField_2);
		textField_2.setColumns(10);
		
		
		JButton btnNewButton_2 = new JButton("\u8FD4\u56DE");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});
		btnNewButton_2.setBounds(462, 319, 93, 23);
		contentPane.add(btnNewButton_2);
		
		JLabel lblNewLabel = new JLabel("\u5171\u6709\uFF08\u672C\uFF09");
		lblNewLabel.setBounds(23, 323, 70, 15);
		contentPane.add(lblNewLabel);
		
		textField_3 = new JTextField();
		textField_3.setBounds(82, 320, 66, 21);
		contentPane.add(textField_3);
		textField_3.setColumns(10);
		
		
		JPanel panel = new JPanel();
		panel.setBounds(23, 38, 532, 271);
		contentPane.add(panel);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 46, 300, 150);
		panel.add(scrollPane);
		
		String []Name = {"���", "����", "����", "������","����","���ݼ��","״̬","����"};
		Object [][] rowData = new Object [100][8];           
		JTable table = new JTable(rowData, Name);
		table.setBounds(297, 179, -279, -124);
		table.setRowHeight(30);                          //�����и�
		table.getColumnModel().getColumn(0).setPreferredWidth(110); //��һ���п�
		table.setPreferredScrollableViewportSize(new Dimension(500 ,300));    //���ù�������ӿڴ�С�������ô�С����������Ҫ�϶���������
		scrollPane.setViewportView(table);
		//�����ݿ���������ʾ��ҳ��ı��
		try {
			String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=LibraryManagement";
			String userName="sa";
			String userPwd="QWEASDZXC000000";
			Connection dbConn = null;
			
			Statement state = null;
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
			state = dbConn.createStatement();
			String sql0 = "select * from ͼ��";
			ResultSet rs = state.executeQuery(sql0);
			
			Statement stateCnt = dbConn.createStatement();
			String sql1 = "select count(*) from ͼ��";
			ResultSet rs_1 = stateCnt.executeQuery(sql1);
			while(rs_1.next()) {
				textField_3.setText(rs_1.getString(1));
			}//ͳ��
			
			int i = 0;
			while(rs.next() && i<rowData.length) {
					
				rowData[i][0] = rs.getString(1);
				rowData[i][1] = rs.getString(2);   
				rowData[i][2] = rs.getString(3);   
				rowData[i][3] = rs.getString(4);   
				rowData[i][4] = rs.getString(5);
				rowData[i][5] = rs.getString(6);
				rowData[i][6] = rs.getString(7);
				rowData[i][7] = rs.getString(8);
				i++;
			}
			dbConn.close();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (ClassNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		String []item = new String[] {"���","����","����","������","����","���ݼ��","״̬","����"};
				
		JComboBox comboBox = new JComboBox(item);
		comboBox.addItemListener(new ItemListener() {//����Ҫ������
			public void itemStateChanged(ItemEvent e) {
				//textField_2.setText(e.getItem());
			}
		});
		comboBox.setBounds(172, 6, 139, 23);
		contentPane.add(comboBox);
		
		
		JButton btnNewButton = new JButton("\u67E5\u8BE2");
		btnNewButton.addActionListener(new ActionListener() {		//��ѯ
			public void actionPerformed(ActionEvent e) {
				String str = new String(textField_2.getText());					//��Ԫ��
				String str_1 = new String((String) comboBox.getSelectedItem());//����
				//���ı��������б��ȡҪ��ѯ�ķ���
				try {
					String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=LibraryManagement";
					String userName="sa";
					String userPwd="QWEASDZXC000000";
					Connection dbConn = null;
					Statement state = null;
					Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
					dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
					state = dbConn.createStatement();
					
					String sql0 = "select * from ͼ�� where "+str_1+"='"+str+"'" ;
					ResultSet rs = state.executeQuery(sql0);		
					
					Statement stateCnt = dbConn.createStatement();
					String sql1 = "select count(*) from ͼ�� where "+str_1+"='"+str+"'"; 
																//����������	��Ԫ��
					ResultSet rs_1 = stateCnt.executeQuery(sql1);
					int n = 0;
					while(rs_1.next()) {
						textField_3.setText(rs_1.getString(1));
						n= Integer.parseInt(rs_1.getString(1));
					}//ͳ������
					
					int i = 0;
					while(rs.next() && i<rowData.length) {	//��ʾ�������
						rowData[i][0] = rs.getString(1);
						rowData[i][1] = rs.getString(2);   
						rowData[i][2] = rs.getString(3);   
						rowData[i][3] = rs.getString(4);   
						rowData[i][4] = rs.getString(5);
						rowData[i][5] = rs.getString(6);
						rowData[i][6] = rs.getString(7);
						rowData[i][7] = rs.getString(8);
						i++;
					}
					while(i>=n && i<rowData.length) {
						rowData[i][0] = null;
						rowData[i][1] = null;
						rowData[i][2] = null;
						rowData[i][3] = null;
						rowData[i][4] = null;
						rowData[i][5] = null;
						rowData[i][6] = null;
						rowData[i][7] = null;
						i++;
					}
				//ˢ��
					TableModel tml = new DefaultTableModel(rowData,Name);
					table.setModel(tml);
				
					dbConn.close();
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (ClassNotFoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
		
			}
		});
		btnNewButton.setBounds(363, 6, 93, 23);
		contentPane.add(btnNewButton);
		
		
		JButton btnNewButton_1 = new JButton("\u53D6\u6D88");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=LibraryManagement";
					String userName="sa";
					String userPwd="QWEASDZXC000000";
					Connection dbConn = null;
					
					Statement state = null;
					Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
					dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
					state = dbConn.createStatement();
					String sql0 = "select * from ͼ��";
					ResultSet rs = state.executeQuery(sql0);
					
					Statement stateCnt = dbConn.createStatement();
					String sql1 = "select count(*) from ͼ��";
					ResultSet rs_1 = stateCnt.executeQuery(sql1);
					while(rs_1.next()) {
						textField_3.setText(rs_1.getString(1));
					}//ͳ��
					
					int i = 0;
					while(rs.next() && i<rowData.length) {
							
						rowData[i][0] = rs.getString(1);
						rowData[i][1] = rs.getString(2);   
						rowData[i][2] = rs.getString(3);   
						rowData[i][3] = rs.getString(4);   
						rowData[i][4] = rs.getString(5);
						rowData[i][5] = rs.getString(6);
						rowData[i][6] = rs.getString(7);
						rowData[i][7] = rs.getString(8);
						i++;
					}
					TableModel tml = new DefaultTableModel(rowData,Name);
					table.setModel(tml);
					
					dbConn.close();
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (ClassNotFoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnNewButton_1.setBounds(462, 7, 93, 23);
		contentPane.add(btnNewButton_1);
		
	}
}
//这是一个使用Java编写的图书查询界面程序。
// 它利用Swing框架创建了一个图书查询窗口,用户可以根据选择的条件进行图书查询操作。
//
//程序主要包括以下组件:
//
//JTextField:用于输入查询关键字的文本框,以及显示查询结果数量的文本框。
//
//JButton:包括“查询”按钮、"取消"按钮和"返回"按钮。
//
//JLabel:用于显示提示信息,比如查询结果数量。
//
//JComboBox:用于选择查询条件的下拉列表框。
//
//JTable:展示查询结果的表格。
//
//程序的主要功能包括:
//
//连接数据库:使用JDBC连接到本地的SQL Server数据库。
//
//查询数据库:根据用户选择的查询条件和输入的关键字,
// 在数据库中执行查询语句,将查询结果显示在表格中。
//
//统计查询结果数量:根据查询结果的数量,更新显示查询结果数量的文本框。
//
//刷新查询结果:重新查询数据库,并将查询结果刷新到表格中。
//
//取消操作:关闭当前窗口。
//
//程序的入口是main方法,在main方法中创建了一个BookFind对象,
// 然后设置窗口的大小和位置,并将其显示出来。
//
//程序中的数据库连接和查询操作使用了try-catch语句块来捕获可能发生的异常,
// 并在catch块中打印异常堆栈信息。
//
//总体来说,这是一个简单的图书查询界面程序,
// 用户可以通过输入关键字和选择查询条件来查询图书信息,并将查询结果展示在表格中。

LEND

package Testv1;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.Calendar;
import java.awt.event.ActionEvent;
import java.awt.Color;

public class Lend extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Lend frame = new Lend();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Lend() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 633, 414);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		
		JButton btnNewButton_1 = new JButton("\u8FD4\u56DE");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});
		btnNewButton_1.setBounds(514, 342, 93, 23);
		contentPane.add(btnNewButton_1);
		
		
		JLabel lblNewLabel_1 = new JLabel("\u8F93\u5165\u4E66\u53F7");
		lblNewLabel_1.setBounds(10, 315, 54, 15);
		contentPane.add(lblNewLabel_1);
		
		textField_1 = new JTextField();
		textField_1.setBounds(63, 312, 93, 21);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		JLabel lblNewLabel_2 = new JLabel("\u64CD\u4F5C\u6210\u529F");
		lblNewLabel_2.setBounds(163, 346, 54, 15);
		contentPane.add(lblNewLabel_2);
		lblNewLabel_2.setVisible(false);		//������
		
		JLabel lblNewLabel = new JLabel("\u64CD\u4F5C\u5931\u8D25");
		lblNewLabel.setForeground(Color.RED);
		lblNewLabel.setBounds(113, 346, 54, 15);
		contentPane.add(lblNewLabel);
		lblNewLabel.setVisible(false);
		
		
		JPanel panel = new JPanel();
		panel.setBounds(10, 10, 597, 295);
		contentPane.add(panel);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 46, 300, 150);
		panel.add(scrollPane);
		
		String []Name = {"���", "����", "����", "������","����","���ݼ��","״̬","����"};
		Object [][] rowData = new Object [100][8];           
		JTable table = new JTable(rowData, Name);
		table.setBounds(297, 179, -279, -124);
		table.setRowHeight(30);                          //�����и�
		table.getColumnModel().getColumn(0).setPreferredWidth(110); //��һ���п�
		table.setPreferredScrollableViewportSize(new Dimension(580 ,300));    //���ù�������ӿڴ�С�������ô�С����������Ҫ�϶���������
		scrollPane.setViewportView(table);
		
		try {
			String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=LibraryManagement";
			String userName="sa";
			String userPwd="QWEASDZXC000000";
			Connection dbConn = null;
			
			Statement state = null;
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
			state = dbConn.createStatement();
			String sql0 = "select * from ͼ��";
			ResultSet rs = state.executeQuery(sql0);
			
			int i = 0;
			while(rs.next() && i<rowData.length) {
					
				rowData[i][0] = rs.getString(1);
				rowData[i][1] = rs.getString(2);   
				rowData[i][2] = rs.getString(3);   
				rowData[i][3] = rs.getString(4);   
				rowData[i][4] = rs.getString(5);
				rowData[i][5] = rs.getString(6);
				rowData[i][6] = rs.getString(7);
				rowData[i][7] = rs.getString(8);
				i++;
			}
			dbConn.close();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (ClassNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		JLabel lblNewLabel_3 = new JLabel("\u4E00\u6B21\u6700\u591A\u501F8\u672C");
		lblNewLabel_3.setForeground(Color.RED);
		lblNewLabel_3.setBounds(221, 315, 93, 15);
		contentPane.add(lblNewLabel_3);
		lblNewLabel_3.setVisible(false);
		
		
		JButton btnNewButton = new JButton("\u67E5\u8BE2");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {			//��ѯ
				BookFind bf = new BookFind();
				bf.setVisible(true);
			}
		});
		
		btnNewButton.setBounds(514, 311, 93, 23);
		contentPane.add(btnNewButton);
		JButton btnNewButton_2 = new JButton("\u501F\u9605");
		btnNewButton_2.addActionListener(new ActionListener() {//����
			public void actionPerformed(ActionEvent e) {
				String textBook = new String(textField_1.getText());
				String num = new String();
				String name = new String();
				String Bname = new String();
				String tmp = null;
				String status = null;
				
				try {
					String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=LibraryManagement";
					String userName="sa";
					String userPwd="QWEASDZXC000000";
					Connection dbConn = null;
					
					Statement state = null;
					Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
					dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
					state = dbConn.createStatement();
					//String sql0 = "select * from ͼ��";
					//ResultSet rs = state.executeQuery(sql0);
					
					String sql0 = "select top 1* from �����˺� order by ʱ�� desc";
					ResultSet rs = state.executeQuery(sql0);		//���һ��
					String s1 = new String();
					while(rs.next()) {
						s1 = rs.getString(1);
					}
					num = s1;//�˺�
					
					Statement sta = dbConn.createStatement();
					String sql = "select count(*) from ���� where ����֤��='"+num+"'";
					ResultSet re = sta.executeQuery(sql);
					while(re.next()) {
						tmp = re.getString(1);			//��¼һ�����˶��ٱ�
					}
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (ClassNotFoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				if(tmp.equals("8")) { //һ��������8����
					lblNewLabel_3.setVisible(true);
					lblNewLabel_2.setVisible(false);
					
				}
				else {
					try{
						String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=LibraryManagement";
						String userName="sa";
						String userPwd="QWEASDZXC000000";
						Connection dbConn = null;
					
						Statement state = null;
						Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
						dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
						state = dbConn.createStatement();
					
						Statement state_1 = dbConn.createStatement();
						String sql1 = "select * from ������ where ����֤��='"+num+"'";
						ResultSet rs1 = state_1.executeQuery(sql1);
						String s2 = new String();
						while(rs1.next()) {
							s2 = rs1.getString(2);
						}
						name = s2;
					
						Statement state_2 = dbConn.createStatement();
						String sql2 = "select * from ͼ�� where ���='"+textBook+"'";
						ResultSet rs2 = state_2.executeQuery(sql2);
						String s3 = new String();
						while(rs2.next()) {
							s3 = rs2.getString(2);
						}
						Bname = s3;		//����
					
						Statement state_4 = dbConn.createStatement();
						String sql3 = "select * from ͼ�� where ���='"+textBook+"'";
						ResultSet rs3 = state_4.executeQuery(sql3);
						String s4 = new String();
						while(rs3.next()) {
							s4 = rs3.getString("״̬");
						}
						status = s4;
						
						if(status.equals("�ѽ��")) {
							lblNewLabel.setVisible(true);
						}
						else {
							lblNewLabel.setVisible(false);
						Calendar c = Calendar.getInstance();
					
						PreparedStatement pst = null;
						pst = dbConn.prepareStatement("insert into ���� values(?,?,?,?,?)");
						pst.setString(1, num);
						pst.setString(2, name);
						pst.setString(3, textBook);
						pst.setString(4, Bname);
						pst.setTimestamp(5, new Timestamp(c.getTimeInMillis()));
						pst.addBatch();
						pst.executeBatch();
					
						PreparedStatement pst1 = null;
						pst1 = dbConn.prepareStatement("update ͼ�� set ״̬=? where ���=?");
						pst1.setString(1, "�ѽ��");
						pst1.setString(2, textBook);
						pst1.addBatch();
						pst1.executeBatch();
					
						lblNewLabel_2.setVisible(true);
						
						String sql0 = "select * from ͼ��";
						ResultSet rs = state.executeQuery(sql0);
						
						int i = 0;
						while(rs.next() && i<rowData.length) {
								
							rowData[i][0] = rs.getString(1);
							rowData[i][1] = rs.getString(2);   
							rowData[i][2] = rs.getString(3);   
							rowData[i][3] = rs.getString(4);   
							rowData[i][4] = rs.getString(5);
							rowData[i][5] = rs.getString(6);
							rowData[i][6] = rs.getString(7);
							rowData[i][7] = rs.getString(8);
							i++;
						}
						//ˢ��
						TableModel tml = new DefaultTableModel(rowData,Name);
						table.setModel(tml);
						dbConn.close();
						}
					} catch (SQLException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
						lblNewLabel.setVisible(true);
						lblNewLabel_2.setVisible(false);
					} catch (ClassNotFoundException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
						lblNewLabel.setVisible(true);
						lblNewLabel_2.setVisible(false);
					}
					if(lblNewLabel_2.isVisible()) {
						lblNewLabel.setVisible(false);
					}
				}
			}
		});
		btnNewButton_2.setBounds(10, 342, 93, 23);
		contentPane.add(btnNewButton_2);
	}

}
//这段代码是一个图书借阅管理系统的界面类。
// 它使用了Java Swing库来创建图形用户界面(GUI)。
// 主要功能包括显示图书列表、查询图书、借阅图书等操作。
//
//代码主要结构如下:
//
//导入所需的包。
//创建一个继承自JFrame的类Lend,作为主窗口。
//在构造方法中设置窗口属性及布局。
//创建各种控件,如JLabel、JTextField、JButton等,并设置其位置、事件监听等。
//创建一个面板Panel,并在面板上添加一个滚动条JScrollPane和一个表格JTable,用于显示图书列表。
//在try-catch块中连接数据库,并执行查询语句,将查询结果填充到表格中。
//在查询按钮的事件监听中,打开另一个窗口BookFind,用于查询图书信息。
//在借阅按钮的事件监听中,获取输入的图书编号、当前用户编号等信息,
// 并根据借阅规则进行判断,如果满足条件则向数据库中插入一条借阅记录,并更新图书状态和表格数据。
//最后通过main方法启动程序。
//需要注意的是,这段代码仅包含了界面的实现,
// 并未完整实现整个图书借阅管理系统的功能,例如数据库连接、借阅规则、图书查询等功能还需要根据具体
// 需求进行完善。

lend-manage

package Testv1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.Calendar;
import java.awt.event.ActionEvent;
//借阅管理的图形用户界面
public class lend_manage extends JFrame {

	private JPanel contentPane;
	private JTextField textField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					lend_manage frame = new lend_manage();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	//初始化界面
	public lend_manage() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 560, 406);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(10, 10, 524, 286);
		contentPane.add(panel);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 46, 300, 150);
		panel.add(scrollPane);
	//用于借阅管理的图形用户界面,基于JScrollPane实现一个表格


		String []Name = {"����֤��", "����", "���", "����","����ʱ��"};
		Object [][] rowData = new Object [100][5];           
		JTable table = new JTable(rowData, Name);
		table.setBounds(297, 179, -279, -124);
		table.setRowHeight(30);                          //�����и�
		table.getColumnModel().getColumn(0).setPreferredWidth(110); //��һ���п�
		table.setPreferredScrollableViewportSize(new Dimension(500 ,300));    //���ù�������ӿڴ�С�������ô�С����������Ҫ�϶���������
		scrollPane.setViewportView(table);
	//上面的代码片段是表格的数据部分,
		// 可以看出是初始化了一个JTable并添加到了JScrollPane中。
		try {
			String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=LibraryManagement";
			String userName="sa";
			String userPwd="QWEASDZXC000000";
			Connection dbConn = null;
			
			Statement state = null;
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
			state = dbConn.createStatement();
			String sql0 = "select * from ���� order by ����ʱ�� asc";
			ResultSet rs = state.executeQuery(sql0);
	//这是一个Java代码片段,将使用JDBC连接到SQL Server数据库,
			// 并执行SQL查询。
			int i = 0;
			while(rs.next() && i<rowData.length) {
					
				rowData[i][0] = rs.getString(1);
				rowData[i][1] = rs.getString(2);   
				rowData[i][2] = rs.getString(3);   
				rowData[i][3] = rs.getString(4);   
				rowData[i][4] = rs.getString(5);
				i++;
			}
			dbConn.close();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (ClassNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		//上面的代码片段是JDBC读取到sql查询结果后,
		// 把查询到的数据记录到数据对象rowData中。然后关闭数据库连接。
		// 请注意,这里只是简单的将 rs 中读取到的数据记录到数组中,
		// 没有任何异常处理或其他的查询操作防御措施,
		// 需要根据具体项目情况进行适当的处理。
		textField = new JTextField();
		textField.setBounds(74, 306, 73, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JLabel lblNewLabel = new JLabel("\u8F93\u5165\u4E66\u53F7");
		lblNewLabel.setBounds(10, 309, 54, 15);
		contentPane.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("\u64CD\u4F5C\u6210\u529F");
		lblNewLabel_1.setBounds(113, 338, 54, 15);
		contentPane.add(lblNewLabel_1);
		lblNewLabel_1.setVisible(false);
		
		JLabel lblNewLabel_2 = new JLabel("\u64CD\u4F5C\u5931\u8D25");
		lblNewLabel_2.setForeground(Color.RED);
		lblNewLabel_2.setBounds(166, 338, 54, 15);
		contentPane.add(lblNewLabel_2);
		lblNewLabel_2.setVisible(false);
//这是一个简单Swing界面的代码片段,包含了一个输入框、
// 两个标签(一个绿色字体的标签用于显示成功信息,一个红色字体的标签用于显示失败信息)。
// 代码中使用了 setContentPane()、setLayout(null)、setBounds()、setColumns() 等方法,
// 通过这些方法实现在 JFrame 上添加和设置标签和输入框。
// 在代码中采用 setVisible() 作为控制标签的可见性的方法,
// 即根据操作的结果来改变标签的可见性。以下是完整的代码:
		
		JButton btnNewButton = new JButton("\u8FD4\u56DE");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});
		btnNewButton.setBounds(441, 334, 93, 23);
		contentPane.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("\u66F4\u6539\u5F52\u8FD8");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String Bnum = new String(textField.getText());
				Calendar c = Calendar.getInstance();
				String tm = null;
				
				try {
					String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=LibraryManagement";
					String userName="sa";
					String userPwd="QWEASDZXC000000";
					Connection dbConn = null;
				
					Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
					dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
					
					String Unum = null;
					Statement state_1 = dbConn.createStatement();
					String sql1 = "select * from ���� where ���='"+Bnum+"'";
					ResultSet rs1 = state_1.executeQuery(sql1);
					String s1 = new String();
					while(rs1.next()) {
						s1 = rs1.getString("����֤��");
					}
					Unum = s1;
//这段代码是一个Java Swing界面的实现,两个按钮分别为“返回”和“修改归还”。
// 单击“返回”按钮时,界面将被隐藏;单击“修改归还”按钮时,将从输入文本框中获取书籍编号,
// 接着获取当前日期和时间来更新书籍归还的日期和时间。
// 之后,程序会将获取的书籍编号和归还日期和时间存储到SQL Server数据库中。
// 其中,使用类似的方式从数据库中获取书籍信息。需要注意的是,代码中的文本的编码格式为Unicode。
					String name = null;
					Statement state_2 = dbConn.createStatement();
					String sql2 = "select * from ���� where ���='"+Bnum+"'";
					ResultSet rs2 = state_2.executeQuery(sql2);
					String s2 = new String();
					while(rs2.next()) {
						s2 = rs2.getString("����");
					}
					name = s2;
				
					String Bname = null;
					Statement state_3 = dbConn.createStatement();
					String sql3 = "select * from ���� where ���='"+Bnum+"'";
					ResultSet rs3 = state_3.executeQuery(sql3);
					while(rs3.next()) {
						Bname = rs3.getString("����");
					}
										
					Statement state_4 = dbConn.createStatement();
					String sql4 = "select ����ʱ�� from ���� where ��� = '"+Bnum+"'";
					ResultSet rs_4 = state_4.executeQuery(sql4);
					while(rs_4.next()) {
						tm = rs_4.getString(1);		//ʱ���
					}
					
					PreparedStatement pst2 = null;		//���뻹���
					pst2 = dbConn.prepareStatement("insert into ���� values(?,?,?,?,?,?)");//����֤�ţ���������ţ�����������ʱ�䣬����ʱ��
					pst2.setString(1, Unum);
					pst2.setString(2, name);
					pst2.setString(3, Bnum);
					pst2.setString(4, Bname);
					pst2.setString(5, tm);
					pst2.setTimestamp(6, new Timestamp(c.getTimeInMillis()));
					pst2.addBatch();
					pst2.executeBatch();
					
					PreparedStatement pst1 = null;
					pst1 = dbConn.prepareStatement("update ͼ�� set ״̬=? where ���=?");
					pst1.setString(1, "�����ڲ�");
					pst1.setString(2, Bnum);
					pst1.addBatch();
					pst1.executeBatch();
				
					String sql0 = "delete from ���� where ���= ?";
					PreparedStatement pst = dbConn.prepareStatement(sql0);//ɾ��
					pst.setString(1, Bnum);
					pst.addBatch();
					pst.executeBatch();
					
					Statement state_1_1 = dbConn.createStatement();
					String sql1_1 = "select * from ���� order by ����ʱ�� asc";
					ResultSet rs_1 = state_1_1.executeQuery(sql1_1);
//这段代码执行了SQL语句,用于更新图书的状态(从借出到归还)和借阅记录的信息。
// 首先从数据库中获取了书籍的相关信息(书籍名称、借阅人姓名等),
// 然后从数据库中获取了该书籍的借阅时间。接着,将获取的相关信息和当前时间存储到借阅记录表中。
// 更新借阅记录表的操作使用PreparedStatement对象进行。
// 接着,使用不同的PreparedStatement对象,通过update语句将图书的状态改为“已归还”。
// 最后,将该书籍对应的借阅记录从借阅记录表中删除。最后的SELECT语句获得了借阅记录表,
// 并按照图书归还时间的升序排列。这段代码的执行可以将图书的借阅状态和借阅记录进行更新。
					int i = 0;
					while(rs_1.next() && i<rowData.length) {
						rowData[i][0] = rs_1.getString(1);
						rowData[i][1] = rs_1.getString(2);   
						rowData[i][2] = rs_1.getString(3);  
						rowData[i][3] = rs_1.getString(4);   
						rowData[i][4] = rs_1.getString(5);
						
						i++;
					}
					while(i<rowData.length) {
						rowData[i][0] = null;
						rowData[i][1] = null;   
						rowData[i][2] = null;   
						rowData[i][3] = null;
						rowData[i][4] = null;
						
						i++;
					}
					//ˢ��
					TableModel tml = new DefaultTableModel(rowData,Name);
					table.setModel(tml);
					
					dbConn.close();
					lblNewLabel_1.setVisible(true);
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
					lblNewLabel_2.setVisible(true);
					lblNewLabel_1.setVisible(false);
				} catch (ClassNotFoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
					lblNewLabel_2.setVisible(true);
					lblNewLabel_1.setVisible(false);
				}
				//这段代码用于获取借阅记录表,并将其展示在Swing界面的表格当中。
				// 首先,使用while循环从借阅记录表中获取每一条借阅记录,
				// 并将记录的各字段值存储在二维数组rowData中。每次循环读取的记录条数不超过rowData数组的长度。
				// 在循环结束后,如果实际读取的记录条数小于rowData数组的长度,
				// 则将后面未读取的记录设置为null。
				// 然后,使用通过数组rowData和数组Name创建TableModel对象,
				// 并将其应用于Swing表格中。最后,关闭数据库连接。
				// 如果在执行SQL查询、连接数据库或关闭连接的过程中出现异常,则会在Swing界面上显示相应的提示信息。
				if(lblNewLabel_1.isVisible()) {
					lblNewLabel_2.setVisible(false);
				}
				if(lblNewLabel_2.isVisible()) {
					lblNewLabel_1.setVisible(false);
				}
				
			}
		});
		btnNewButton_1.setBounds(10, 334, 93, 23);
		contentPane.add(btnNewButton_1);
		
		JButton btnNewButton_2 = new JButton("\u8FD8\u4E66\u8BB0\u5F55");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Retrun_table rb = new Retrun_table();
				rb.setVisible(true);
			}
		});
		btnNewButton_2.setBounds(441, 306, 93, 23);
		contentPane.add(btnNewButton_2);
		
	}

}
//这段代码创建了两个按钮,分别为“修改归还”和“还书记录”。单击“还书记录”按钮时,会打开一个新的窗口,显示所有还书记录的信息。
// 这段代码完成了界面的创建,并为两个按钮设置相应的事件监听器。
// 其中,setVisible方法用于隐藏或显示Swing组件。

Loglnpage

package Testv1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.FlowLayout;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class LogInPage extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					LogInPage frame = new LogInPage();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public LogInPage() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("ͼ�����ϵͳ");
		lblNewLabel.setBounds(130, 10, 174, 34);
		lblNewLabel.setFont(new Font("����", Font.PLAIN, 29));
		contentPane.add(lblNewLabel);
		
		JButton btnNewButton = new JButton("\u7BA1\u7406\u5458\u767B\u5F55");
		btnNewButton.setFont(new Font("����", Font.PLAIN, 17));
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Manager_Login MPage = new Manager_Login();
				MPage.setVisible(true);
				/*Page_3 win3 =new Page_3();
				win3.setVisible(true);
			*/
			}
		});
		btnNewButton.setBounds(146, 92, 144, 39);
		contentPane.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("\u8BFB\u8005\u767B\u5F55");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				User_Login UPage = new User_Login();
				UPage.setVisible(true);
			}
		});
		btnNewButton_1.setFont(new Font("����", Font.PLAIN, 17));
		btnNewButton_1.setBounds(146, 159, 144, 39);
		contentPane.add(btnNewButton_1);
	}
}
//这是一个Java代码片段,可能是用于登录页面的图形用户界面
//个类继承自JFrame,因此是一个窗口。它包括一个容器JPanel和两个按钮JButton和一个标签JLabel,
// 用于显示和选择不同的登录选项。在构造函数中,
// 设置窗口的大小和关闭操作,然后添加按钮和标签到容器中。
// 需要根据实际需求,给这些组件添加事件监听器、添加图标、设置样式等等。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值