简单的java图手册馆管理系统.docx

上传人:b****7 文档编号:9124522 上传时间:2023-02-03 格式:DOCX 页数:26 大小:44.51KB
下载 相关 举报
简单的java图手册馆管理系统.docx_第1页
第1页 / 共26页
简单的java图手册馆管理系统.docx_第2页
第2页 / 共26页
简单的java图手册馆管理系统.docx_第3页
第3页 / 共26页
简单的java图手册馆管理系统.docx_第4页
第4页 / 共26页
简单的java图手册馆管理系统.docx_第5页
第5页 / 共26页
点击查看更多>>
下载资源
资源描述

简单的java图手册馆管理系统.docx

《简单的java图手册馆管理系统.docx》由会员分享,可在线阅读,更多相关《简单的java图手册馆管理系统.docx(26页珍藏版)》请在冰豆网上搜索。

简单的java图手册馆管理系统.docx

简单的java图手册馆管理系统

课程设计题目

图书馆管理系统

一、设计环境

DBMS:

mysql

开发工具:

eclipse

应用程序开发环境:

win8.1

系统运行环境:

win8.1

二、概要设计

(1)功能:

1.创建图书馆界面(凭账号密码登陆)

2.对数据库进行图书的查找、修改、添加、删除

3.实时显示图书馆数据的改变

(2)E—R图

(3)流程图

(4)表

(5)数据

(6)连接数据库代码

Connectionconn=null;

Class.forName();

conn=DriverManager.getConnection(,"root","panda1993");

4、详细设计

(1)主界面Login.java

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

publicclassLoginextendsJFrame{

privatestaticfinallongserialVersionUID=1L;//?

?

?

?

privateJLabeljlUsername;

privateJLabeljlPwd;

privateJTextFieldtxtUsername;//?

?

?

privateJTextFieldtxtPassword;//?

?

privateJButtonjbOk;

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.LIGHT_GRAY);

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("C:

\\Users\\Zpanda\\Desktop\\web\\bookStore\\images\\1.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);//?

?

?

?

?

?

?

?

?

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

myEvent();

this.setVisible(true);

this.setResizable(false);//?

?

?

?

?

?

?

?

?

?

}

privatevoidmyEvent(){

jbCancel.addActionListener(newActionListener()

{

publicvoidactionPerformed(ActionEvente)

{

Login.this.dispose();

}

});

jbOk.addActionListener(newActionListener()

{

publicvoidactionPerformed(ActionEvente)

{

Connectionconn=null;

Statementstm=null;

ResultSetst=null;

try

{

Class.forName();

conn=DriverManager.getConnection(,"root","panda1993");

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("?

?

?

?

?

?

?

?

");

}

}

(2)管理界面Book.java

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

import

publicclassBookextendsJFrame{

privatestaticfinallongserialVersionUID=1L;

privateJLabellblId;

privateJLabellblBname;

privateJLabellblWname;

privateJLabellblCbs;

privateJLabellblnum1;

privateJLabellblnum2;

privateJTextFieldbId;//?

?

?

?

privateJTextFieldbname;//?

?

privateJTextFieldwname;//?

?

?

privateJTextFieldcbs;//?

?

?

privateJTextFieldnum1;//?

?

?

privateJTextFieldnum2;//?

?

?

privateJButtonjbDel;

privateJTextFieldjDel;

privateJButtonjbAdd;

privateJButtonjbSearch;

privateJButtonjbUpdate;

privateJTabletable;//?

?

?

?

privateJLabeljabel;//?

?

?

?

?

?

?

?

privateJScrollPanescpDemo;

privateObjectbtnShow;

@SuppressWarnings("unused")

privateObjectjth;

publicJLabelgetJabel(){

if(jabel==null)

{

jabel=newJLabel("?

?

?

?

");

jabel.setForeground(Color.red);

jabel.setBounds(450,350,60,30);

}

returnjabel;

}

publicJButtongetJbDel(){

if(jbDel==null)

{

jbDel=newJButton("?

?

");

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

}

returnjbDel;

}

publicJTextFieldgetjDel(){

if(jDel==null)

{

jDel=newJTextField(20);

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

}

returnjDel;

}

publicJButtongetJbAdd(){

if(jbAdd==null)

{

jbAdd=newJButton("?

?

");

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

}

returnjbAdd;

}

publicJButtongetJbSearch(){

if(jbSearch==null)

{

jbSearch=newJButton("?

?

");

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

}

returnjbSearch;

}

publicJButtongetJbUpdate(){

if(jbUpdate==null)

{

jbUpdate=newJButton("?

?

");

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

}

returnjbUpdate;

}

@SuppressWarnings("serial")

publicJTablegetTable(){

JTabletable=newJTable(20,3){//?

?

JTable?

?

?

?

?

?

?

?

publicComponentprepareRenderer(TableCellRendererrenderer,introw,intcolumn){

Componentc=super.prepareRenderer(renderer,row,column);

if(cinstanceofJComponent){

((JComponent)c).setOpaque(false);

}

returnc;

}

};

table.setOpaque(false);//?

?

jtable?

?

?

?

?

?

this.setSize(450,400);

this.setLayout(null);

this.setLocation(270,50);

this.scpDemo=newJScrollPane();

this.scpDemo.setBounds(10,100,420,270);

this.scpDemo.setOpaque(false);//?

?

this.scpDemo.getViewport().setOpaque(false);//?

?

this.btnShow=newJButton("?

?

?

?

(?

?

)");

((Component)this.btnShow).setBounds(10,50,420,30);

((AbstractButton)this.btnShow).addActionListener(newActionListener(){

publicvoidactionPerformed(ActionEventae){

btnShow_ActionPerformed(ae);

}

});

add(this.scpDemo);

add((Component)this.btnShow);

this.setVisible(true);

returntable;

}

publicvoidbtnShow_ActionPerformed(ActionEventae){

Connectionconn=null;

try{

Class.forName();

conn=DriverManager.getConnection(,"root","panda1993");

Statementpstm=conn.createStatement();

Stringsql1="selectcount(*)fromBook";

Stringsql2="select*fromBook";

ResultSetrs1=pstm.executeQuery(sql1);

intcount=0;

//?

?

?

?

?

?

if(rs1.next()){

count=rs1.getInt

(1);

}

//?

?

?

?

?

?

?

?

rs1.close();

Object[][]info=newObject[count][6];

count=0;

//?

?

ResultSetrs2=pstm.executeQuery(sql2);

while(rs2.next()){

info[count][0]=rs2.getString("Bid");

info[count][1]=rs2.getString("Bname");

info[count][2]=rs2.getString("Wname");

info[count][3]=rs2.getString("num1");

info[count][4]=rs2.getString("num2");

info[count][5]=rs2.getString("chubs");

count++;

}

for(Object[]o:

info){

System.out.println(o[0]);

System.out.println(o[1]);

System.out.println(o[2]);

System.out.println(o[3]);

System.out.println(o[4]);

}

String[]title={"?

?

","?

?

","?

?

","?

?

?

","?

?

?

","?

?

?

"};

//?

?

JTable

this.table=newJTable(info,title);

//?

?

?

?

this.jth=this.table.getTableHeader();

//?

JTable?

?

?

?

?

?

?

?

?

?

?

this.scpDemo.getViewport().add(table);

}catch(Exceptionsqle){

JOptionPane.showMessageDialog(null,"?

?

:

"+sqle.getMessage(),"?

?

",

JOptionPane.ERROR_MESSAGE);

}

}

publicJLabelgetLblId(){

if(lblId==null)

{

lblId=newJLabel("?

?

");

lblId.setForeground(Color.red);

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

}

returnlblId;

}

publicJLabelgetLblBname(){

if(lblBname==null)

{

lblBname=newJLabel("?

?

");

lblBname.setForeground(Color.red);

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

}

returnlblBname;

}

publicJLabelgetLblWname(){

if(lblWname==null)

{

lblWname=newJLabel("?

?

");

lblWname.setForeground(Color.red);

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

}

returnlblWname;

}

publicJLabelgetLblnum1(){

if(lblnum1==null)

{

lblnum1=newJLabel("?

?

?

");

lblnum1.setForeground(Color.red);

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

}

returnlblnum1;

}

publicJLabelgetLblnum2(){

if(lblnum2==null)

{

lblnum2=newJLabel("?

?

?

");

lblnum2.setForeground(Color.red);

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

}

returnlblnum2;

}

publicJTextFieldgetbId(){

if(bId==null)

{

bId=newJTextField(20);

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

}

returnbId;

}

public

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

当前位置:首页 > 小学教育 > 小学作文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1