📄 brborrowinfo.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package libsystem;/** * 浏览所有读者信息 * @author admin */import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;public class BrBorrowInfo extends JFrame{ private Statement stmt; private ResultSet rs; private Object data[][]= new Object[60][7];//表数据 private Object columnName[]={"借阅号","书号","学号","借出","借出日期","归还","归还日期"}; private JPanel panel; private JButton closebut = new JButton("关闭"); private JTable table = new JTable(data, columnName);//构造一个显示二维表数据,及一维列名的表格 public BrBorrowInfo() { Container con = getContentPane(); con.setLayout(new FlowLayout()); this.setBounds(250,50,490,500); this.setTitle("浏览所有借阅信息"); closebut.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { dispose(); } }); closebut.setBounds(800,500,80,30); con.add(closebut); con.add(table); Container container = getContentPane(); //创建一个面板 container.add(new JScrollPane(table),FlowLayout.LEFT); //添加滚动窗口到面板上 this.setVisible(true); //设里窗体可见 this.validate(); //显示全部信息 int i = 0; while(i>=0) { //清空上次查询结果 data[i][0] = ""; data[i][1] = ""; data[i][2] = ""; data[i][3] = ""; data[i][4] = ""; data[i][5] = ""; data[i][6] = ""; i--; } repaint(); i = 0; try { stmt = ConnDataBase.getConnection().createStatement(); rs=stmt.executeQuery("Select * From Borrow");//显示表中的全部记录 while(rs.next()) { //处理查询过程 data[i][0] = rs.getString("借阅号");//从数据库表中取出一个记录的学号字段 data[i][1] = rs.getString("书号"); data[i][2] = rs.getString("学号"); data[i][3] = rs.getString("借出"); data[i][4] = rs.getString("借出日期"); data[i][5] = rs.getString("归还"); data[i][6] = rs.getString("归还日期"); i++;//统计 } } catch(Exception e1){ } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -