Java编写的简单图书管理系统word文档良心出品Word格式.docx

上传人:b****1 文档编号:4531795 上传时间:2023-05-03 格式:DOCX 页数:24 大小:305.06KB
下载 相关 举报
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第1页
第1页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第2页
第2页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第3页
第3页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第4页
第4页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第5页
第5页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第6页
第6页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第7页
第7页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第8页
第8页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第9页
第9页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第10页
第10页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第11页
第11页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第12页
第12页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第13页
第13页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第14页
第14页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第15页
第15页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第16页
第16页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第17页
第17页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第18页
第18页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第19页
第19页 / 共24页
Java编写的简单图书管理系统word文档良心出品Word格式.docx_第20页
第20页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

Java编写的简单图书管理系统word文档良心出品Word格式.docx

《Java编写的简单图书管理系统word文档良心出品Word格式.docx》由会员分享,可在线阅读,更多相关《Java编写的简单图书管理系统word文档良心出品Word格式.docx(24页珍藏版)》请在冰点文库上搜索。

Java编写的简单图书管理系统word文档良心出品Word格式.docx

privateJButtonjbCancel;

publicJLabelgetJlUsername(){

if(jlUsername==null)

{

jlUsername=newJLabel("

账号"

);

jlUsername.setForeground(Color.BLACK);

jlUsername.setBounds(118,40,85,30);

}

returnjlUsername;

}

publicJLabelgetJlPwd(){

if(jlPwd==null)

jlPwd=newJLabel("

密码"

jlPwd.setForeground(Color.BLACK);

jlPwd.setBounds(118,100,85,30);

returnjlPwd;

publicJTextFieldgetTxtUsername(){

if(txtUsername==null)

txtUsername=newJTextField(20);

txtUsername.setBounds(180,40,200,30);

returntxtUsername;

publicJTextFieldgetTxtPassword(){

if(txtPassword==null)

txtPassword=newJPasswordField(20);

txtPassword.setBounds(180,100,200,30);

returntxtPassword;

publicJButtongetJbOk(){

if(jbOk==null)

jbOk=newJButton("

登陆"

jbOk.setBounds(150,180,90,30);

//jbOk.addActionListener(this);

returnjbOk;

publicJButtongetJbCancel(){

if(jbCancel==null)

jbCancel=newJButton("

取消"

jbCancel.setBounds(300,180,90,30);

returnjbCancel;

publicLogin(Stringtitle)

{

super(title);

//JFrameframe=newJFrame();

Containercantainer=this.getContentPane();

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

ImageIconimg=newImageIcon("

F:

\\Java\\传习\\src\\Library\\ZF`XY`H48I_}U)C4~}M2~C4.jpg"

//这是背景图片

JLabelimgLabel=newJLabel(img);

//将背景图放在标签里。

this.getLayeredPane().add(imgLabel,newInteger(Integer.MIN_VALUE));

//注意这里是关键,将背景标签添加到jfram的LayeredPane面板里。

imgLabel.setBounds(0,0,img.getIconWidth(),img.getIconHeight());

//设置背景标签的位置

cantainer.setLayout(newBorderLayout());

imgLabel.setLayout(null);

imgLabel.add(getJlUsername());

imgLabel.add(getTxtUsername());

imgLabel.add(getJlPwd());

imgLabel.add(getTxtPassword());

imgLabel.add(getJbOk());

imgLabel.add(getJbCancel());

cantainer.add(imgLabel,BorderLayout.NORTH);

((JPanel)cantainer).setOpaque(false);

//注意这里,将内容面板设为透明。

这样LayeredPane面板中的背景才能显示出来。

this.setSize(img.getIconWidth(),img.getIconHeight());

myEvent();

this.setVisible(true);

this.setResizable(true);

privatevoidmyEvent(){

jbCancel.addActionListener(newActionListener()

publicvoidactionPerformed(ActionEvente)

{

Login.this.dispose();

}

});

jbOk.addActionListener(newActionListener()

Connectionconn=null;

Statementstm=null;

ResultSetst=null;

try

{

Class.forName("

com.mysql.jdbc.Driver"

conn=DriverManager.getConnection("

jdbc:

mysql:

//localhost:

3306/library"

"

sa"

123456"

stm=conn.createStatement();

Stringsql="

select*fromuser"

;

//Stringsql1="

selectpswfromuser"

st=stm.executeQuery(sql);

//st1=stm.executeQuery(sql1);

if(st.next())

{

if(txtUsername.getText().equals(st.getString("

id"

))&

&

txtPassword.getText().equals(st.getString("

psw"

)))

{

Login.this.setVisible(false);

newBook("

管理界面"

}

else

JOptionPane.showMessageDialog(null,"

您输入的账号或密码不正确"

getTxtUsername().setText("

"

getTxtPassword().setText("

}

else

JOptionPane.showMessageDialog(null,"

用户名不存在,请重新输入,错误!

getTxtUsername().setText("

getTxtPassword().setText("

}

catch(ClassNotFoundExceptione1)

e1.printStackTrace();

}catch(SQLExceptione2){

//TODOAuto-generatedcatchblock

e2.printStackTrace();

}finally{

try{

stm.close();

}catch(Exceptione3){}

//关闭Connection

try{conn.close();

}catch(Exceptione4){}

}

publicstaticvoidmain(String[]args)

newLogin("

图书管理登陆界面"

}

管理界面

实现代码

importjavax.swing.JTable;

publicclassBookextendsJFrame{

privateJLabellblId;

privateJLabellblBname;

privateJLabellblWname;

privateJLabellblCbs;

privateJLabellblnum1;

privateJLabellblnum2;

privateJTextFieldbId;

//图书编号

privateJTextFieldbname;

//书名

privateJTextFieldwname;

//作者名

privateJTextFieldcbs;

//出版社

privateJTextFieldnum1;

//现存量

privateJTextFieldnum2;

//库存量

privateJButtonjbDel;

privateJTextFieldjDel;

privateJButtonjbAdd;

privateJButtonjbSearch;

privateJButtonjbUpdate;

privateJTabletable;

privateJLabeljabel;

//输入要查找的书号

publicJLabelgetJabel(){

if(jabel==null)

jabel=newJLabel("

查删学号"

jabel.setBounds(50,350,50,30);

returnjabel;

publicJButtongetJbDel(){

if(jbDel==null)

jbDel=newJButton("

删除"

jbDel.setBounds(180,400,60,30);

returnjbDel;

publicJTextFieldgetjDel(){

if(jDel==null)

jDel=newJTextField(20);

jDel.setBounds(100,350,150,30);

returnjDel;

publicJButtongetJbAdd(){

if(jbAdd==null)

jbAdd=newJButton("

添加"

jbAdd.setBounds(100,400,60,30);

returnjbAdd;

publicJButtongetJbSearch(){

if(jbSearch==null)

jbSearch=newJButton("

查找"

jbSearch.setBounds(100,450,60,30);

returnjbSearch;

publicJButtongetJbUpdate(){

if(jbUpdate==null)

jbUpdate=newJButton("

修改"

jbUpdate.setBounds(180,450,60,30);

returnjbUpdate;

publicJTablegetTable(){

if(table==null)

table=newJTable(100,6);

table.setBounds(270,50,500,600);

returntable;

publicJLabelgetLblId(){

if(lblId==null)

lblId=newJLabel("

编号"

lblId.setBounds(50,50,50,30);

returnlblId;

publicJLabelgetLblBname(){

if(lblBname==null)

lblBname=newJLabel("

书名"

lblBname.setBounds(50,100,50,30);

returnlblBname;

publicJLabelgetLblWname(){

if(lblWname==null)

lblWname=newJLabel("

作者"

lblWname.setBounds(50,150,50,30);

returnlblWname;

publicJLabelgetLblnum1(){

if(lblnum1==null)

lblnum1=newJLabel("

现存量"

lblnum1.setBounds(50,200,50,30);

returnlblnum1;

publicJLabelgetLblnum2(){

if(lblnum2==null)

lblnum2=newJLabel("

库存量"

lblnum2.setBounds(50,250,50,30);

returnlblnum2;

publicJTextFieldgetbId(){

if(bId==null)

bId=newJTextField(20);

bId.setBounds(100,50,150,30);

returnbId;

publicJTextFieldgetBname(){

if(bname==null)

bname=newJTextField(20);

bname.setBounds(100,100,150,30);

returnbname;

publicJTextFieldgetWname(){

if(wname==null)

wname=newJTextField(20);

wname.setBounds(100,150,150,30);

returnwname;

publicJTextFieldgetNum1(){

if(num1==null)

num1=newJTextField(20);

num1.setBounds(100,200,150,30);

returnnum1;

publicJTextFieldgetNum2(){

if(num2==null)

num2=newJTextField(20);

num2.setBounds(100,250,150,30);

returnnum2;

publicJLabelgetLblCbs(){

if(lblCbs==null)

lblCbs=newJLabel("

出版社"

lblCbs.setBounds(50,300,50,30);

returnlblCbs;

publicJTextFieldgetCbs(){

if(cbs==null)

cbs=newJTextField(20);

cbs.setBounds(100,300,150,30);

returncbs;

publicBook(Stringtitle)

\\Java\\传习\\src\\Library\\d50735fae6cd7b8961e8eafd0f2442a7d8330ecc[1].jpg"

imgLabel.add(getLblId());

imgLabel.add(getbId());

imgLabel.add(getLblBname());

imgLabel.add(getBname());

imgLabel.add(getLblWname());

imgLabel.add(getWname());

imgLabel.add(getLblnum1());

imgLabel.add(getNum1());

imgLabel.add(getLblnum2());

imgLabel.add(getNum2());

imgLabel.add(getLblCbs());

imgLabel.add(getCbs());

imgLabel.add(getTable());

imgLabel.add(getJbDel());

imgLabel.add(getjDel());

imgLabel.add(getJbA

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 考试认证 > 交规考试

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2