图书管理系统是一个用于图书馆或书店管理图书信息、借阅记录和读者信息的应用程序。本系统使用Java Swing框架进行开发,提供直观的用户界面,方便图书馆管理员或书店工作人员对图书信息进行管理。以下是系统的设计、功能和实现的详细报告。
技术选型:
前端框架: Java Swing
后端语言: Java
数据库: 使用文件存储图书信息
系统架构:
MVC(Model-View-Controller)架构,以确保系统的可维护性和扩展性。
Model: 数据模型,包括图书、读者和借阅记录等类。
View: 用户界面,使用Swing组件实现各种窗口和表格。
Controller: 控制器,处理用户输入、调用业务逻辑和更新视图。
图书管理:
添加图书信息,包括书名、作者、出版社、出版日期等。
修改图书信息,支持编辑已有图书的属性。
删除图书,从系统中移除不需要的图书。
查询图书,根据书名、作者等条件进行搜索。
读者管理:
添加读者信息,包括姓名、学号(或工号)、联系方式等。
修改读者信息,更新读者的个人信息。
删除读者,从系统中注销读者账号。
查询读者,根据姓名、学号等条件进行搜索。
借阅管理:
借书,记录图书的借阅信息,包括借阅日期和应还日期。
还书,更新图书的借阅状态,计算逾期天数和罚金。
查询借阅记录,查看读者的借阅历史。
登录界面: 提供用户名和密码登录系统。
主界面: 显示图书管理、读者管理和借阅管理等功能按钮。
图书管理界面: 包括添加、修改、删除和查询图书的功能。
读者管理界面: 包括添加、修改、删除和查询读者的功能。
借阅管理界面: 包括借书、还书和查询借阅记录的功能。
CREATE TABLE book_admin
(
username
varchar(20) NOT NULL COMMENT ‘用户名’,
password
varchar(20) NOT NULL COMMENT ‘密码’,
PRIMARY KEY (username
),
UNIQUE KEY UNIQUE
(username
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE book_info
(
bookId
int NOT NULL AUTO_INCREMENT COMMENT ‘图书id’,
bookName
varchar(50) NOT NULL COMMENT ‘图书名称’,
author
varchar(50) NOT NULL COMMENT ‘图书作者’,
– 其他字段…
PRIMARY KEY (bookId
),
UNIQUE KEY UNIQUE
(bookName
)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
CREATE TABLE book_lend
(
lendId
int NOT NULL AUTO_INCREMENT COMMENT ‘借阅id’,
bookName
varchar(50) NOT NULL COMMENT ‘图书名称’,
userName
varchar(20) NOT NULL COMMENT ‘借阅者名称’,
– 其他字段…
PRIMARY KEY (lendId
)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
CREATE TABLE book_type
(
typeId
int NOT NULL AUTO_INCREMENT COMMENT ‘类别id’,
typeName
varchar(50) NOT NULL COMMENT ‘类别名称’,
typeDesc
varchar(100) DEFAULT NULL COMMENT ‘类别描述’,
PRIMARY KEY (typeId
),
UNIQUE KEY UNIQUE
(typeName
)
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
CREATE TABLE book_user
(
username
varchar(20) NOT NULL COMMENT ‘用户名’,
password
varchar(20) NOT NULL COMMENT ‘密码’,
PRIMARY KEY (username
),
UNIQUE KEY UNIQUE
(username
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
InfoFrame.java
package com.wang.view.minorframe;
import com.wang.utils.ImageData;
import com.wang.view.baseview.MinorFrame;
import javax.swing.*;
import java.awt.*;
/**
* 关于我们界面
*/
public class InfoFrame extends MinorFrame {
public InfoFrame() {
super("关于我们",840,590);
initFrame();
}
private void initFrame(){
JPanel jp = new JPanel(){
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
ImageData.info.paintIcon(this, g, 0, 0);
}
};
jp.setLayout(null);
JLabel jl1 = new JLabel("欢迎使用图书管理系统!");
jl1.setBounds(20,20,600,50);
jl1.setFont(new Font("方正舒体", Font.PLAIN, 40));
JLabel jl2 = new JLabel("工作邮箱:xxx");
jl2.setBounds(20,70,600,50);
jl2.setFont(new Font("方正舒体", Font.PLAIN, 40));
jp.add(jl1);
jp.add(jl2);
setContentPane(jp);
}
}
LendBookFrame.java
package com.wang.view.minorframe;
import com.wang.bean.Book;
import com.wang.bean.LendInfo;
import com.wang.service.BookService;
import com.wang.service.LendInfoService;
import com.wang.service.TypeService;
import com.wang.service.impl.BookServiceImpl;
import com.wang.service.impl.LendInfoServiceImpl;
import com.wang.service.impl.TypeServiceImpl;
import com.wang.view.baseview.MinorFrame;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Date;
import java.util.*;
import java.util.List;
/**
* 借阅图书界面
*/
public class LendBookFrame extends MinorFrame {
private JTable table;
private DefaultTableModel tdm;
private final BookService bookService = new BookServiceImpl();
private final TypeService typeService = new TypeServiceImpl();
private final LendInfoService lendInfoService = new LendInfoServiceImpl();
private JRadioButton jrb1, jrb2;
private JComboBox<String> jcb1, jcb2;
private JTextField jtf1, jtf2, jtf3, jtf4, jtf5, jtf6;
private JTextArea jta;
public LendBookFrame(String username) {
super("图书借阅", 800, 650);
initFrame(username);
}
private void initFrame(String username){
JPanel jp = new JPanel() {
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawLine(120, 330, getWidth() - 50, 330);
g.drawLine(50, 580, getWidth() - 50, 580);
g.drawLine(50, 330, 50, 580);
g.drawLine(getWidth() - 50, 330, getWidth() - 50, 580);
g.drawLine(120, 30, getWidth() - 50, 30);
g.drawLine(50, 100, getWidth() - 50, 100);
g.drawLine(50, 30, 50, 100);
g.drawLine(getWidth() - 50, 30, getWidth() - 50, 100);
}
};
jp.setLayout(null);
initTable();
JLabel jl1 = new JLabel("搜索条件");
JLabel jl2 = new JLabel("图书名称:");
JLabel jl3 = new JLabel("图书作者:");
JLabel jl4 = new JLabel("图书类别:");
JLabel jl5 = new JLabel("表单操作");
JLabel jl6 = new JLabel("图书名称:");
JLabel jl7 = new JLabel("图书作者:");
JLabel jl8 = new JLabel("作者性别:");
JLabel jl9 = new JLabel("图书价格:");
JLabel jl10 = new JLabel("图书库存:");
JLabel jl11 = new JLabel("图书类别:");
JLabel jl12 = new JLabel("图书描述:");
jtf1 = new JTextField();
jtf2 = new JTextField();
jtf3 = new JTextField();
jtf4 = new JTextField();
jtf5 = new JTextField();
jtf6 = new JTextField();
jta = new JTextArea(20, 20);
jta.setLineWrap(true);
JScrollPane j = new JScrollPane();
jrb1 = new JRadioButton("男");
jrb2 = new JRadioButton("女");
ButtonGroup bg = new ButtonGroup();
bg.add(jrb1);
bg.add(jrb2);
jrb1.setSelected(true);
jcb1 = new JComboBox<>();
jcb2 = new JComboBox<>();
JButton jb1 = new JButton("查询");
JButton jb2 = new JButton("借阅");
JScrollPane jsp = new JScrollPane(table);
jtf3.setEnabled(false);
jtf4.setEnabled(false);
jtf5.setEnabled(false);
jtf6.setEnabled(false);
jta.setEnabled(false);
jcb2.setEnabled(false);
jrb1.setEnabled(false);
jrb2.setEnabled(false);
jl1.setBounds(57, 20, 70, 20);
jl2.setBounds(60, 55, 70, 20);
jl3.setBounds(237, 55, 70, 20);
jl4.setBounds(385, 55, 70, 20);
jl5.setBounds(57, 320, 70, 20);
jtf1.setBounds(125, 57, 100, 20);
jtf2.setBounds(302, 57, 70, 20);
jb1.setBounds(657, 42, 60, 20);
jb2.setBounds(657, 72, 60, 20);
jsp.setBounds(50, 125, 686, 180);
jcb1.setBounds(455, 57, 180, 20);
jcb2.setBounds(510, 397, 180, 20);
jl6.setBounds(100, 355, 70, 20);
jl7.setBounds(310, 355, 70, 20);
jl8.setBounds(520, 355, 70, 20);
jtf3.setBounds(170, 357, 130, 20);
jtf4.setBounds(380, 357, 130, 20);
jrb1.setBounds(590, 355, 40, 20);
jrb2.setBounds(640, 355, 40, 20);
jl9.setBounds(100, 395, 70, 20);
jl10.setBounds(270, 395, 70, 20);
jl11.setBounds(440, 395, 70, 20);
jtf5.setBounds(170, 397, 90, 20);
jtf6.setBounds(340, 397, 90, 20);
jl12.setBounds(100, 438, 70, 20);
j.setBounds(170, 440, 522, 120);
fillBookTypeName();
j.setViewportView(jta);
jp.add(jl1);
jp.add(jl2);
jp.add(jl3);
jp.add(jl4);
jp.add(jl5);
jp.add(jl6);
jp.add(jl7);
jp.add(jl8);
jp.add(jl9);
jp.add(jl10);
jp.add(jl11);
jp.add(jl12);
jp.add(jtf1);
jp.add(jtf2);
jp.add(jtf3);
jp.add(jtf4);
jp.add(jtf5);
jp.add(jtf6);
jp.add(j);
jp.add(jrb1);
jp.add(jrb2);
jp.add(jcb1);
jp.add(jcb2);
jp.add(jb1);
jp.add(jb2);
jp.add(jsp);
table.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
bookMousePressed();
}
});
jb1.addActionListener(this::searchAction);
jb2.addActionListener(actionEvent ->lendAction(username));
setContentPane(jp);
}
//查询按钮
private void searchAction(ActionEvent e) {
//表格先清空选择
table.removeRowSelectionInterval(0, table.getRowCount() - 1);
//模糊查找
String strOfName = jtf1.getText().trim();
String strOfAuthor = jtf2.getText().trim();
//
String strOfType = (String) jcb1.getSelectedItem();
if ("".equals(strOfName) && "".equals(strOfAuthor) && "请选择……".equals(strOfType)) {
JOptionPane.showMessageDialog(null, "请输入查询信息!", "警告", JOptionPane.WARNING_MESSAGE);
return;
}
List<Book> list = new ArrayList<>();
if (!"".equals(strOfName)) {
list.addAll(bookService.getBookListByBookName(strOfName));
}
if (!"".equals(strOfAuthor)) {
list.addAll(bookService.getBookListByAuthor(strOfAuthor));
}
if (!"".equals(strOfType)) {
list.addAll(bookService.getBookListByTypeName(strOfType));
}
if (list.size() == 0) {
JOptionPane.showMessageDialog(null, "未查询到指定结果!");
return;
}
for (Book book : list) {
for (int j = 0; j < tdm.getRowCount(); j++) {
//将查询到的book根据书名得到表中行数选择得到的行数
if (book.getBookId().equals(table.getValueAt(j, 0))) {
table.addRowSelectionInterval(j, j);
break;
}
}
}
//随机展出一个查询到的book对象的信息
Book book = list.get((int) ((Math.random() * 100) % list.size()));
jtf3.setText(book.getBookName());
jtf4.setText(book.getAuthor());
jtf5.setText(String.valueOf(book.getPrice()));
jtf6.setText(String.valueOf(book.getBookNum()));
jta.setText(book.getBookDesc());
if ("男".equals(book.getGender())) {
jrb1.setSelected(true);
} else {
jrb2.setSelected(true);
}
jcb2.setSelectedItem(book.getTypeName());
JOptionPane.showMessageDialog(null, "共查询到" + table.getSelectedRowCount() + "条结果!");
}
//借阅按钮
private void lendAction(String username) {
if (table.getSelectedRowCount() > 1) {
JOptionPane.showMessageDialog(null, "不支持同时借阅多本图书!", "警告", JOptionPane.WARNING_MESSAGE);
return;
}
//获取选中行
int row = table.getSelectedRow();
if (row == - 1) { //没有选择
JOptionPane.showMessageDialog(null, "请选择待借阅图书!", "警告", JOptionPane.WARNING_MESSAGE);
return;
}
if (Integer.parseInt(String.valueOf(table.getValueAt(row, 5))) == 0) {
JOptionPane.showMessageDialog(null, "该书无库存!", "警告", JOptionPane.WARNING_MESSAGE);
return;
}
int isFlag = JOptionPane.showConfirmDialog(null, "是否借阅?");
if (isFlag > 0) {
return;
}
String bookName = (String) table.getValueAt(row, 1);
//执行借阅
bookService.lendBook(bookName); //库存减一
//填入借阅信息
lendInfoService.lendBook(new LendInfo(null, bookName, username, new Date(System.currentTimeMillis()), "未归还"));
//更新数量
Long newNum = (Long) table.getValueAt(row, 5) - 1;
table.setValueAt(newNum, row, 5);
jtf6.setText(String.valueOf(newNum));
JOptionPane.showMessageDialog(null, "借阅成功!");
}
//监听鼠标点击事件
private void bookMousePressed() {
int row = table.getSelectedRow();
jtf3.setText(String.valueOf(table.getValueAt(row, 1)));
jtf4.setText(String.valueOf(table.getValueAt(row, 2)));
jtf5.setText(String.valueOf(table.getValueAt(row, 4)));
jtf6.setText(String.valueOf(table.getValueAt(row, 5)));
String gender = String.valueOf(table.getValueAt(row, 3));
if ("男".equals(gender)) {
jrb1.setSelected(true);
} else {
jrb2.setSelected(true);
}
String typeName = String.valueOf(table.getValueAt(row, 6));
jcb2.setSelectedItem(typeName);
jta.setText(String.valueOf(table.getValueAt(row, 7)));
}
//初始化表格
private void initTable() {
//创建表格
String[] columnNames = {"编号", "图书名称", "作者", "作者性别", "图书价格","图书库存", "图书类别", "图书描述"};
Object[][] rowType = bookService.getAllBookToArray();
tdm = new DefaultTableModel(rowType, columnNames);
table = new JTable(tdm) {
@Override
public boolean isCellEditable(int row, int column) {
return false; //不可编辑,但可以选择
}
};
//
DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();//单元格渲染器
dtcr.setHorizontalAlignment(JLabel.CENTER);//居中显示
table.setDefaultRenderer(Object.class, dtcr);//设置渲染器t
table.getColumnModel().getColumn(0).setPreferredWidth(30);
table.getColumnModel().getColumn(1).setPreferredWidth(100);
table.getColumnModel().getColumn(2).setPreferredWidth(100);
table.getColumnModel().getColumn(3).setPreferredWidth(50);
table.getColumnModel().getColumn(4).setPreferredWidth(50);
table.getColumnModel().getColumn(5).setPreferredWidth(50);
table.getColumnModel().getColumn(6).setPreferredWidth(100);
table.getColumnModel().getColumn(7).setPreferredWidth(180);
table.getTableHeader().setReorderingAllowed(false); //不可改变列的位置
}
//初始化类别下拉菜单
private void fillBookTypeName() {
jcb1.addItem("请选择……");
jcb2.addItem("请选择……");
List<com.wang.bean.Type> types = typeService.getAllTypeToList();
for (com.wang.bean.Type type : types) {
jcb1.addItem(type.getTypeName());
jcb2.addItem(type.getTypeName());
}
}
}
OwnLendInfoFrame.java
package com.wang.view.minorframe;
import com.wang.bean.LendInfo;
import com.wang.service.BookService;
import com.wang.service.LendInfoService;
import com.wang.service.impl.BookServiceImpl;
import com.wang.service.impl.LendInfoServiceImpl;
import com.wang.view.baseview.MinorFrame;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import java.sql.Date;
/**
* 个人借阅信息界面
*/
public class OwnLendInfoFrame extends MinorFrame {
private JTable table;
private DefaultTableModel tdm;
private final LendInfoService lendInfoService = new LendInfoServiceImpl();
private final BookService bookService = new BookServiceImpl();
public OwnLendInfoFrame(String username, boolean isFlag) {
super("个人借阅信息", 500, 350);
initFrame(username,isFlag);
}
private void initFrame(String username,boolean isFlag) {
JPanel jp = new JPanel();
jp.setLayout(null);
initTable(username, isFlag);
JScrollPane j = new JScrollPane(table);
j.setBounds(30, 30, 425, 220);
jp.add(j);
if (isFlag) {
JButton jb = new JButton("归还");
jp.add(jb);
jb.setBounds(360, 260, 60, 20);
jb.addActionListener(actionEvent -> returnAction(username));
}
setContentPane(jp);
}
//归还按钮
private void returnAction(String username) {
if (table.getSelectedRowCount() > 1) {
JOptionPane.showMessageDialog(null, "不支持同时归还多本图书!", "警告", JOptionPane.WARNING_MESSAGE);
return;
}
//获取选中行
int row = table.getSelectedRow();
if (row == - 1) { //没有选择
JOptionPane.showMessageDialog(null, "请选择待归还图书!", "警告", JOptionPane.WARNING_MESSAGE);
return;
}
int isFlag = JOptionPane.showConfirmDialog(null, "是否归还?");
if (isFlag > 0) {
return;
}
int lendId = (int) table.getValueAt(row, 0);
String bookName = (String) table.getValueAt(row, 1);
Date lendDate = (Date) table.getValueAt(row, 2);
bookService.returnBook(bookName); //库存加一
lendInfoService.returnBook(new LendInfo(lendId, bookName, username, lendDate, new Date(System.currentTimeMillis()).toString())); //填入归还日期
tdm.removeRow(row);
JOptionPane.showMessageDialog(null, "归还成功!");
}
//初始化表格
private void initTable(String username,boolean isFlag) {
//创建表格
String[] columnNames = {"借阅编号", "图书名称", "借阅时间", "归还时间"};
Object[][] rowType;
if(isFlag) {
rowType = lendInfoService.getOwnLendInfo(username);
} else{
rowType = lendInfoService.getOwnReturnInfo(username);
}
tdm = new DefaultTableModel(rowType, columnNames);
table = new JTable(tdm) {
@Override
public boolean isCellEditable(int row, int column) {
return false; //不可编辑,但可以选择
}
};
//
DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();//单元格渲染器
dtcr.setHorizontalAlignment(JLabel.CENTER);//居中显示
table.setDefaultRenderer(Object.class, dtcr);//设置渲染器t
table.getColumnModel().getColumn(0).setPreferredWidth(60);
table.getColumnModel().getColumn(1).setPreferredWidth(205);
table.getColumnModel().getColumn(2).setPreferredWidth(80);
table.getColumnModel().getColumn(3).setPreferredWidth(80);
table.getTableHeader().setReorderingAllowed(false); //不可改变列的位置
}
}
RegisterFrame.java
package com.wang.view.minorframe;
import com.wang.bean.User;
import com.wang.service.UserService;
import com.wang.service.impl.UserServiceImpl;
import com.wang.utils.ImageData;
import com.wang.view.baseview.MinorFrame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
/**
* 用户注册界面
*/
public class RegisterFrame extends MinorFrame {
private JTextField jtf;
private JPasswordField jpf1, jpf2;
private JButton jb1, jb3;
private final UserService userService = new UserServiceImpl();
public RegisterFrame() {
super("注册框", 500, 380);
initFrame();
}
private void initFrame(){
JPanel jp = new JPanel(){
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
ImageData.bg.paintIcon(this, g, 0, 0);
}
};
jp.setLayout(null);
JLabel jl1 = new JLabel();
JLabel jl2 = new JLabel();
JLabel jl3 = new JLabel();
jl1.setText(" 用 户 名:");
jl1.setIcon(ImageData.un);
jl2.setText(" 密 码:");
jl2.setIcon(ImageData.pw);
jl3.setText(" 确认密码:");
jl3.setIcon(ImageData.pw);
jl1.setBounds(60, 45, 165, 25);
jl2.setBounds(60, 100, 165, 25);
jl3.setBounds(60, 155, 165, 25);
jl1.setFont(new Font("方正舒体", Font.PLAIN, 25));
jl2.setFont(new Font("方正舒体", Font.PLAIN, 25));
jl3.setFont(new Font("方正舒体", Font.PLAIN, 25));
jtf = new JTextField();
jpf1 = new JPasswordField();
jpf2 = new JPasswordField();
jtf.setBounds(225, 48, 200, 25);
jtf.setFont(new Font("方正舒体", Font.PLAIN, 25));
jpf1.setBounds(225, 103, 200, 25);
jpf1.setFont(new Font("方正舒体", Font.PLAIN, 25));
jpf1.setEchoChar('\u2605');
jpf2.setBounds(225, 158, 200, 25);
jpf2.setFont(new Font("方正舒体", Font.PLAIN, 25));
jpf2.setEchoChar('\u2605');
jb1 = new JButton("确认");
JButton jb2 = new JButton("取消");
jb3 = new JButton("重置");
jb1.setBounds(70, 230, 80, 40);
jb1.setFont(new Font("方正舒体", Font.PLAIN, 20));
jb2.setBounds(200, 230, 80, 40);
jb2.setFont(new Font("方正舒体", Font.PLAIN, 20));
jb3.setBounds(330, 230, 80, 40);
jb3.setFont(new Font("方正舒体", Font.PLAIN, 20));
jtf.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
char c = e.getKeyChar();
if (c == KeyEvent.VK_ENTER) {
jpf1.grabFocus();
}
}
});
jpf1.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
char c = e.getKeyChar();
if (c == KeyEvent.VK_ENTER) {
jpf2.grabFocus();
}
}
});
jpf2.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
char c = e.getKeyChar();
if (c == KeyEvent.VK_ENTER) {
jb1.doClick();
}
}
});
jp.add(jl1);
jp.add(jl2);
jp.add(jl3);
jp.add(jtf);
jp.add(jpf1);
jp.add(jpf2);
jp.add(jb1);
jp.add(jb2);
jp.add(jb3);
jb1.addActionListener(this::registerAction);
jb2.addActionListener(this::cancelAction);
jb3.addActionListener(this::resetAction);
setContentPane(jp);
}
//注册按钮
private void registerAction(ActionEvent e) {
String username = jtf.getText().trim();
String password1 = String.valueOf(jpf1.getPassword()).trim();
String password2 = String.valueOf(jpf2.getPassword()).trim();
if ("".equals(username)) {
JOptionPane.showMessageDialog(null, "用户名不能为空!", "警告", JOptionPane.WARNING_MESSAGE);
return;
}
if ("".equals(password1)) {
JOptionPane.showMessageDialog(null, "密码不能为空!", "警告", JOptionPane.WARNING_MESSAGE);
return;
}
if ("".equals(password2)) {
JOptionPane.showMessageDialog(null, "请确认你的密码!", "警告", JOptionPane.WARNING_MESSAGE);
return;
}
if (!password1.equals(password2)) {
JOptionPane.showMessageDialog(null, "两次输入的密码不一致!", "警告", JOptionPane.WARNING_MESSAGE);
jb3.doClick();
return;
}
if ("root".equals(username)) {
JOptionPane.showMessageDialog(null, "用户名已存在!", "错误", JOptionPane.ERROR_MESSAGE);
jb3.doClick();
return;
}
User user = new User(username, password1);
boolean isSuccess = userService.registerUser(user);
if (isSuccess) {
JOptionPane.showMessageDialog(null, "注册成功!");
this.dispose();
} else {
JOptionPane.showMessageDialog(null, "用户名已存在!", "错误", JOptionPane.ERROR_MESSAGE);
jb3.doClick();
}
}
//取消按钮
private void cancelAction(ActionEvent e) {
this.dispose();
}
//重置按钮
private void resetAction(ActionEvent e) {
jtf.setText("");
jpf1.setText("");
jpf2.setText("");
}
}
图书管理系统采用Java Swing框架,实现了图书、读者和借阅记录的基本管理功能。通过清晰的系统设计、直观的用户界面和严谨的测试,确保了系统的可用性和稳定性。未来的改进方向可以考虑引入更复杂的数据库系统、增加图书推荐算法等功能,提升系统的智能化和用户体验。
q:969060742 文档、代码、sql、程序资源