1、广西外国语学院信息工程学院 面向对象java程序设计 试验汇报班级网络工程1301姓名李亮锋学号日期试验地点试验名称广外图书馆管理系统一. 试验目标1、掌握Java图形用户设计Swing常见组件。2、掌握SQL Server 数据库、数据表创建和使用。3、掌握事件监听机制。4、熟悉使用SQL语言操作数据库,如增加、删除、查询和修改等。5、熟悉应用程序开发步骤。6、程序打包和安装。7、锻炼学生逻辑思维。试验设备(仪器、材料、软件等)硬件:计算机软件:JDK、Eclipse三、试验内容本系统将会包含到图书馆日常管理工作基础常见细节,诸如新图书入库登记,图书馆全部书籍分类管理,图书查询,图书借阅、退
2、还手续登记,费旧图书清理撤消等,本系统所要实现这些功效基础上涵盖了图书馆日常管理工作,基础能够满足校园图书馆工作人员管理需要。在对本系统具体开发过程当中,将采取Java语言进行开发,以SQLServer实现后台数据库,本系统是完全基于图形化用户界面(GUI)单机版本。四、试验步骤请参见教材第20章综合案例快递打印系统格式来书写,要求有界面和关键代码。图书馆管理系统要有信息:用户登录(注册),新图书入库,图书信息查询,图书更新(修改),旧图书删除,办理借阅证登记,图书借阅管理,软件说明及相关作者等。以下是示例,每个同学能够有自己功效设计和数据库设计。系统功效结构图书入库对应数据库学生信息表对应数
3、据库用户信息表对应数据库(一)图书菜单主菜单源代码以下:package book;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.AbstractAction;import javax.swing.Icon;import javax.swing.ImageIcon;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMen
4、u;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JPanel;import llf.frane.Login;import booksystem.BookDelete;import booksystem.BookQuery;import booksystem.BookUpdate;import booksystem.Dengji;public class MainFrame extends JFrameJMenuBar menubar=null;JMenu jm=null;JPanel j
5、p;/图片Icon icon;/图片JLabel jl;/图片public MainFrame()setSize(558,370);setTitle(广外图书管理系统);setJMenuBar(getJMenuBar1();setLocationRelativeTo(null);setResizable(false); private JMenuBar getJMenuBar1() / TODO Auto-generated method stubif(menubar=null)menubar=new JMenuBar();JMenu jm1=new JMenu(菜单);JMenu jm2=n
6、ew JMenu(选项);JMenu jm3=new JMenu(帮助);menubar.add(jm1);menubar.add(jm2);menubar.add(jm3);JMenuItem bookinsert=new JMenuItem(新图书入库);JMenuItem bookquery=new JMenuItem(图书信息查询);JMenuItem bookupdate=new JMenuItem(图书更新);JMenuItem bookdelete=new JMenuItem(旧图书删除); JMenuItem bookexit=new JMenuItem(退出系统); JMen
7、uItem dengji=new JMenuItem(办理借阅证登记); JMenuItem manage=new JMenuItem(图书借阅管理); JMenuItem denglu=new JMenuItem(用户登陆); JMenuItem introduce=new JMenuItem(软件说明); JMenuItem author =new JMenuItem(相关作者); jm1.add(bookinsert); jm1.add(bookquery); jm1.add(bookupdate); jm1.add(bookdelete);jm1.add(bookexit);jm2.a
8、dd(dengji);jm2.add(manage);jm2.add(denglu);jm3.add(introduce);jm3.add(author);JPanel jp=new JPanel();/图片Icon iocn=new ImageIcon(C:/Users/Administrator/Desktop/李亮锋/tushuguan.JPG);JLabel jl=new JLabel(iocn);/图片jp.add(jl);/图片this.add(jp);/图片bookinsert.addActionListener(new ActionListener() public void
9、actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubBookinsert bi=new Bookinsert();bi.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);bi.setVisible(true););bookquery.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stu
10、bBookQuery bq=new BookQuery();bq.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);bq.setVisible(true););bookupdate.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubBookUpdate bu=new BookUpdate();bu.setDefaultCloseOperation(JFrame.
11、DISPOSE_ON_CLOSE);bu.setVisible(true););bookdelete.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubBookDelete bd=new BookDelete();bd.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);bd.setVisible(true););bookexit.addActionListene
12、r(new ActionListener() /退出public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubSystem.exit(1););dengji.addActionListener(new ActionListener() /办理借阅证登记public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubDengji dj=new Dengji();dj.setDefaultCloseOper
13、ation(JFrame.DISPOSE_ON_CLOSE);dj.setVisible(true););introduce.addActionListener(new ActionListener() /软件说明public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubIntroduce id=new Introduce();id.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);id.setVisible(true););manage.add
14、ActionListener(new ActionListener() /图书借阅管理public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubManage ma=new Manage();ma.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);ma.setVisible(true););denglu.addActionListener(new ActionListener() /登陆public void actionPerformed(Act
15、ionEvent arg0) / TODO Auto-generated method stubLogin lg=new Login();lg.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);lg.setVisible(true););author.addActionListener(new ActionListener() /相关作者public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubAuthor at=new Author();at.
16、setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);at.setVisible(true););return menubar;public static void main(String args) / TODO Auto-generated method stubMainFrame mf=new MainFrame();mf.setVisible(true);mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);(二)登录界面登陆界面源代码以下:package llf.frane;import ja
17、va.awt.Component;import java.awt.Font;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextF
18、ield;public class Login extends JFrameJPanel jP1,jP2,jP3,jP4;JLabel jl1,jl2,jl3;JTextField tf;JPasswordField pf;JButton b1,b2,b3;public Login()jl1=new JLabel(广外图书馆);jl1.setFont(new Font(隶书,Font.BOLD,40);jl2=new JLabel(账户:);jl3=new JLabel(密码:);b1=new JButton(登陆);b2=new JButton(取消);b3=new JButton(重置);
19、tf=new JTextField(15);pf=new JPasswordField(15);jP1=new JPanel();jP2=new JPanel();jP3=new JPanel();jP4=new JPanel();setLayout(new GridLayout(4,1);jP1.add(jl1);jP2.add(jl2);jP2.add(tf);jP3.add(jl3);jP3.add(pf);jP4.add(b1);jP4.add(b2);jP4.add(b3);this.add(jP1);this.add(jP2);this.add(jP3);this.add(jP4)
20、;setTitle(用户登陆);setSize(500,400);setLocationRelativeTo(null);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setVisible(true);b2.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) / TODO Auto-generated method stubSystem.exit(1););b3.addActionListener(new ActionListener(
21、)public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubtf.setText();pf.setText(););public static void main(String args) Login lg=new Login();(三)新图书入库新图书入库源代码package book;import java.awt.GridLayout;import java.awt.HeadlessException;import java.awt.event.ActionEvent;import jav
22、a.awt.event.ActionListener;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.SQLException;import javax.swing.AbstractButton;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.
23、swing.JTextField;import llf.frane.DAO;public class Bookinsert extends JFrame JLabel jl1,jl2,jl3,jl4,jl5;JTextField jt1,jt2,jt3,jt4,jt5;JButton jb1,jb2;JPanel jp1,jp2,jp3,jp4,jp5,jp6;public Bookinsert()setSize(400,300);setTitle(新图书入库);setLocationRelativeTo(null);setDefaultCloseOperation(JFrame.EXIT_O
24、N_CLOSE);setVisible(true);setLayout(new GridLayout(6,1);jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();jp5=new JPanel();jp6=new JPanel();jl1=new JLabel(图书编号);jl2=new JLabel(图书名称);jl3=new JLabel(出版日期);jl4=new JLabel(出版社名称);jl5=new JLabel(图书总数);jt1=new JTextField(15);jt2=new JText
25、Field(15);jt3=new JTextField(15);jt4=new JTextField(15);jt5=new JTextField(15);jb1=new JButton(入库);jb2=new JButton(重置);jp1.add(jl1);jp1.add(jt1);jp2.add(jl2);jp2.add(jt2);jp3.add(jl3);jp3.add(jt3);jp4.add(jl4);jp4.add(jt4);jp5.add(jl5);jp5.add(jt5);jp6.add(jb1);jp6.add(jb2);this.add(jp1);this.add(jp
26、2);this.add(jp3);this.add(jp4);this.add(jp5);this.add(jp6);jb1.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) /System.exit(1);String sname=jt1.getText().trim();String sno=jt2.getText().trim();String sriqi=jt3.getText().trim();String schubanshe=jt4.getText().trim();
27、String szongshu=jt5.getText().trim();String sex;try if(sname.equals()|sno.equals()|sriqi.equals()|schubanshe.equals()|szongshu.equals()JOptionPane.showMessageDialog(null,请输入完整信息);elseConnection conn=null;PreparedStatement ps=null;conn=DAO.getConn();ps=conn.prepareStatement(insert into inputbook valu
28、es (+sname+,+sno+,+sriqi+,+schubanshe+,+szongshu+);int i=ps.executeUpdate();if(i=1)JOptionPane.showMessageDialog(null,入库成功);elseJOptionPane.showMessageDialog(null,入库失败); catch (HeadlessException e1) / TODO Auto-generated catch blocke1.printStackTrace(); catch (SQLException e1) / TODO Auto-generated
29、catch blocke1.printStackTrace(););jb2.addActionListener(new ActionListener()public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubjt1.setText();jt2.setText();jt3.setText();jt4.setText();jt5.setText(););public static void main(String args) / TODO Auto-generated method stubBoo
30、kinsert b=new Bookinsert();b.setVisible(true);b.setResizable(false);(四)图书信息查询图书信息查询源代码以下:package booksystem;import java.awt.GridLayout;import java.awt.HeadlessException;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.PreparedStatement
31、;import java.sql.ResultSet;import java.sql.SQLException;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import llf.frane.DAO;public class BookQuery extends JFrame JLabel jl1,jl2,jl3,
32、jl4;JTextField jf1,jf2,jf3,jf4;/文本JButton jb1;/按钮JPanel jp1,jp2,jp3,jp4;public BookQuery()jl1=new JLabel(查询图书名称:);jl2=new JLabel(图书编号:);jl3=new JLabel(入库日期);jl4=new JLabel(入库总数:);jf1=new JTextField(15);jf2=new JTextField(15);jf3=new JTextField(15);jf4=new JTextField(15);jb1=new JButton(查询);jp1=new J
33、Panel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();this.setLayout(new GridLayout(4, 1);jp1.add(jl1);jp1.add(jf1);jp1.add(jb1);jp2.add(jl2);jp2.add(jf2);jp3.add(jl3);jp3.add(jf3);jp4.add(jl4);jp4.add(jf4);this.add(jp1);this.add(jp2);this.add(jp3);this.add(jp4);setTitle(图书查询);setSize(400,300);
34、setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);setLocationRelativeTo(null);setVisible(true);jb1.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) / TODO Auto-generated method stubString bookname=jf1.getText().trim();Connection conn=null;PreparedStatement ps=null;Re
35、sultSet rs=null;conn=DAO.getConn();try if(bookname.equals()JOptionPane.showMessageDialog(null,请输入你要查询书名);elseString sql=select * from inputbook where bookname=+bookname+;ps=conn.prepareStatement(sql);rs=ps.executeQuery();if(rs.next()jf2.setText(rs.getString(1);jf3.setText(rs.getString(3);elseJOption
36、Pane.showMessageDialog(null,你查询图书不存在); catch (HeadlessException e1) / TODO Auto-generated catch blocke1.printStackTrace(); catch (SQLException e1) / TODO Auto-generated catch blocke1.printStackTrace(););public static void main(String args) / TODO Auto-generated method stubBookQuery bc=new BookQuery(
37、);(五)图书更新图书更新源代码以下:package booksystem;import java.awt.GridLayout;import java.awt.HeadlessException;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import javax.s
38、wing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import llf.frane.DAO;public class BookUpdate extends JFrame JLabel jl1,jl2,jl3,jl4,jl5;JTextField jt1,jt2,jt3,jt4,jt5;/文本JButton jb1,jb2;JPanel jp1,
39、jp2,jp3,jp4,jp5,jp6;public BookUpdate()jl1=new JLabel(图书名称);jl2=new JLabel(图书编号);jl3=new JLabel(入库日期);jl4=new JLabel(入库日期);jl5=new JLabel(入库总数);jt1=new JTextField(15);jt2=new JTextField(15);jt3=new JTextField(15);jt4=new JTextField(15);jt5=new JTextField(15);jb1=new JButton(查询);jb2=new JButton(修改);j
40、p1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();jp5=new JPanel();jp6=new JPanel();setLayout(new GridLayout(6, 1);jp1.add(jl1);jp1.add(jt1);jp2.add(jl2);jp2.add(jt2);jp3.add(jl3);jp3.add(jt3);jp4.add(jl4);jp4.add(jt4);jp5.add(jl5);jp5.add(jt5);jp6.add(jb1);jp6.add(jb2);this.add(jp1
41、);this.add(jp2);this.add(jp3);this.add(jp4);this.add(jp5);this.add(jp6);setTitle(图书更新);setSize(500,350);setLocationRelativeTo(null);setDefaultCloseOperation(DISPOSE_ON_CLOSE);setVisible(true);jb1.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubString bookname=jt1.getText(
©2010-2024 宁波自信网络信息技术有限公司 版权所有
客服电话:4008-655-100 投诉/维权电话:4009-655-100