图书管理系统java代码Word格式.docx
- 文档编号:13517794
- 上传时间:2022-10-11
- 格式:DOCX
- 页数:14
- 大小:17.65KB
图书管理系统java代码Word格式.docx
《图书管理系统java代码Word格式.docx》由会员分享,可在线阅读,更多相关《图书管理系统java代码Word格式.docx(14页珍藏版)》请在冰豆网上搜索。
功能"
//建立“功能”菜单组
Menumhelp=newMenu("
帮助"
//建立“帮助”菜单组
MenuItemmdenglu=newMenuItem("
登陆"
MenuItemmchaxun=newMenuItem("
查询"
MenuItemmtianjia=newMenuItem("
添加"
MenuItemmshanchu=newMenuItem("
删除"
MenuItemmexit=newMenuItem("
退出"
MenuItemmhelpp=newMenuItem("
关于"
Denglupdenglu=newDenglu();
Ptianjiaptianjia=newPtianjia();
Pmainpmain=newPmain();
Pchaxunpchaxun=newPchaxun();
Pshanchupshanchu=newPshanchu();
dbframe(Strings){//在窗口上添加菜单选项
setTitle(s);
mfile.add(mdenglu);
mfile.add(mtianjia);
mfile.add(mchaxun);
mfile.add(mshanchu);
mfile.add(mexit);
mhelp.add(mhelpp);
daohang.add(mfile);
daohang.add(mhelp);
setMenuBar(daohang);
add(pmain);
addWindowListener(newWindowAdapter(){
publicvoidwindowClosing(WindowEvente){
System.exit(0);
}
});
setBounds(200,200,340,250);
setResizable(false);
setVisible(true);
mexit.addActionListener(this);
mdenglu.addActionListener(this);
mtianjia.addActionListener(this);
mchaxun.addActionListener(this);
mshanchu.addActionListener(this);
mhelpp.addActionListener(this);
validate();
}//窗口事件监听
publicvoidactionPerformed(ActionEvente){
if(e.getSource()==mexit)
System.exit(0);
if(e.getSource()==mdenglu){
removeAll();
add(pdenglu);
validate();
}
if(e.getSource()==mtianjia){
add(ptianjia);
}//图书添加功能
if(e.getSource()==mchaxun){
add(pchaxun);
}//图书查询功能
if(e.getSource()==mshanchu){
add(pshanchu);
}//图书删除功能
if(e.getSource()==mhelpp){
JOptionPane.showMessageDialog(this,"
欢迎使用图书管理系统"
"
关于本系统"
JOptionPane.INFORMATION_MESSAGE);
}//各功能菜单事件监听
//
classPtianjiaextendsPanelimplementsActionListener{
TextFieldtname,tauthor,tpublish,tdate,tcomment;
Labellname,lauthor,lpublish,ldate,lcomment;
Buttonbtn;
Ptianjia(){
setLayout(null);
btn=newButton("
//创立“添加”按钮
tname=newTextField();
tauthor=newTextField();
tpublish=newTextField();
tdate=newTextField();
tcomment=newTextField();
//创立5个文本框
lname=newLabel("
书名"
lauthor=newLabel("
作者"
lpublish=newLabel("
出版社"
ldate=newLabel("
出版日期"
lcomment=newLabel("
评论"
add(lname);
add(tname);
add(lauthor);
add(tauthor);
add(lpublish);
add(tpublish);
add(ldate);
add(tdate);
add(lcomment);
add(tcomment);
add(btn);
//添加“按钮”到窗口面板上
lname.setBounds(10,10,70,25);
tname.setBounds(90,10,220,25);
lauthor.setBounds(10,40,70,25);
tauthor.setBounds(90,40,220,25);
lpublish.setBounds(10,70,70,25);
tpublish.setBounds(90,70,220,25);
ldate.setBounds(10,100,70,25);
tdate.setBounds(90,100,220,25);
lcomment.setBounds(10,130,70,25);
tcomment.setBounds(90,130,220,25);
btn.setBounds(130,160,70,25);
//设置按钮位置
btn.addActionListener(this);
//设置按钮监听
setSize(340,250);
//设置窗口大小
setBackground(Color.white);
//设置窗口背景颜色
Stringsname=tname.getText();
Stringsauthor=tauthor.getText();
Stringspublish=tpublish.getText();
Stringsdate=tdate.getText();
Stringscomment=tcomment.getText();
Stringinsertstr="
insertintobookvalues"
+"
("
'
"
+sname+"
+"
"
+sauthor+"
+spublish+"
+sdate+"
+scomment+"
)"
;
//SQL语句
Connectioncon;
Statementsta;
ResultSetrs;
try{
Class.forName("
oracle.jdbc.driver.OracleDriver"
//加载JDBC驱动
}catch(ClassNotFoundExceptionee){
System.out.println("
+ee);
con=DriverManager.getConnection("
jdbc:
oracle:
thin:
@localhost:
1521:
orcl"
sa"
//连接数据库
sta=con.createStatement();
sta.executeUpdate(insertstr);
//执行SQL语句
con.close();
//关闭数据库
tname.setText("
tauthor.setText("
tpublish.setText("
tdate.setText("
tcomment.setText("
//重新初始化文本框内容
添加成功"
图书管理系统"
}catch(SQLExceptioneee){
+eee);
tcomment.setText
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 图书 管理 系统 java 代码