上传者: 27595745
|
上传时间: 2021-07-10 09:04:17
|
文件大小: 91KB
|
文件类型: RAR
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.table.*;
import java.util.Vector;
public class BorrowBookList extends JFrame implements ActionListener
{
DataBaseManager db=new DataBaseManager();
ResultSet rs;
Container c;
JPanel panel1,panel2;
JLabel BookNameLabel,StudentNameLabel;
JTextField BookNameTextField,StudentNameTextField;
JButton SearchBtn,ExitBtn;
JTable table=null;
DefaultTableModel defaultModel=null;
public BorrowBookList()
{
super("书籍借阅一览!");
c=getContentPane();
c.setLayout(new BorderLayout());
BookNameLabel=new JLabel("书名 ",JLabel.CENTER);
StudentNameLabel=new JLabel("借阅者",JLabel.CENTER);
BookNameTextField=new JTextField(15);
StudentNameTextField=new JTextField(15);
SearchBtn=new JButton("查询");
ExitBtn=new JButton("退出");
SearchBtn.addActionListener(this);
ExitBtn.addActionListener(this);
Box box1=Box.createHorizontalBox();
box1.add(StudentNameLabel);
box1.add(StudentNameTextField);
box1.add(SearchBtn);
Box box2=Box.createHorizontalBox();
box2.add(BookNameLabel);
box2.add(BookNameTextField);
box2.add(ExitBtn);
Box boxH=Box.createVerticalBox();
boxH.add(box1);
boxH.add(box2);
boxH.add(Box.createVerticalGlue());
panel1=new JPanel();
panel1.add(boxH);
panel2=new JPanel();
String[] name={"借阅者","书名","借阅日期","还入日期","备注"};
String[][] data=new String[0][0];
defaultModel=new DefaultTableModel(data,name);
table=new JTable(defaultModel);
table.setPreferredScrollableViewportSize(new Dimension(400,80));
JScrollPane s=new JScrollPane(table);
panel2.add(s);
c.add(panel1,BorderLayout.NORTH);
c.add(panel2,BorderLayout.SOUTH);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==ExitBtn)
{
db.closeConnection();
this.dispose();
}
else if(e.getSource()==SearchBtn)
{
String strSQL="select studentname,bookname,borrowdate,returndate,com from bookbrowse";