欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    Java编写的简单图书管理系统(1).doc

    • 资源ID:23970026       资源大小:519.50KB        全文页数:73页
    • 资源格式: DOC        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    Java编写的简单图书管理系统(1).doc

    Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-dateJava编写的简单图书管理系统(1)Java编写的简单图书管理系统Java编写的简单图书管理系统主界面代码实现package Library;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;public class Login extends JFrame private static final long serialVersionUID = 1L;private JLabel jlUsername;private JLabel jlPwd;private JTextField txtUsername; /用户名private JTextField txtPassword; /密码private JButton jbOk;private JButton jbCancel;public JLabel getJlUsername() if(jlUsername=null)jlUsername=new JLabel("账号");jlUsername.setForeground(Color.BLACK);jlUsername.setBounds(118, 40, 85, 30);return jlUsername;public JLabel getJlPwd() if(jlPwd=null)jlPwd=new JLabel("密码");jlPwd.setForeground(Color.BLACK);jlPwd.setBounds(118, 100, 85, 30);return jlPwd;public JTextField getTxtUsername() if(txtUsername=null)txtUsername=new JTextField(20);txtUsername.setBounds(180,40 , 200, 30);return txtUsername;public JTextField getTxtPassword() if(txtPassword=null)txtPassword=new JPasswordField(20);txtPassword.setBounds(180, 100, 200, 30);return txtPassword;public JButton getJbOk() if(jbOk=null)jbOk=new JButton("登陆");jbOk.setBounds(150, 180, 90, 30);/jbOk.addActionListener(this);return jbOk;public JButton getJbCancel() if(jbCancel=null)jbCancel=new JButton("取消");jbCancel.setBounds(300, 180, 90, 30);return jbCancel;public Login(String title)super(title);/JFrame frame=new JFrame();Container cantainer=this.getContentPane();this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);ImageIcon img = new ImageIcon("F:Java传习srcLibraryZFXYH48I_U)C4M2C4.jpg");/这是背景图片JLabel imgLabel = new JLabel(img);/将背景图放在标签里。this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE);/注意这里是关键,将背景标签添加到jfram的LayeredPane面板里。imgLabel.setBounds(0,0,img.getIconWidth(), img.getIconHeight();/设置背景标签的位置cantainer.setLayout(new BorderLayout();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);private void myEvent()jbCancel.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)Login.this.dispose(););jbOk.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)Connection conn=null;Statement stm=null;ResultSet st=null;tryClass.forName("com.mysql.jdbc.Driver");conn=DriverManager.getConnection("jdbc:mysql:/localhost:3306/library","sa","123456");stm=conn.createStatement();String sql="select * from user"/String sql1="select psw from user"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);new Book("管理界面");elseJOptionPane.showMessageDialog(null, "您输入的账号或密码不正确");getTxtUsername().setText("");getTxtPassword().setText("");else JOptionPane.showMessageDialog(null,"用户名不存在,请重新输入,错误!"); getTxtUsername().setText("");getTxtPassword().setText("");catch(ClassNotFoundException e1)e1.printStackTrace(); catch (SQLException e2) / TODO Auto-generated catch blocke2.printStackTrace();finallytrystm.close();catch (Exception e3) / 关闭Connection try conn.close(); catch (Exception e4) );public static void main(String args)new Login("图书管理登陆界面");管理界面实现代码package Library;import java.awt.BorderLayout;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTable;import javax.swing.JTextField;public class Book extends JFrame private static final long serialVersionUID = 1L;private JLabel lblId;private JLabel lblBname;private JLabel lblWname;private JLabel lblCbs;private JLabel lblnum1;private JLabel lblnum2;private JTextField bId; /图书编号private JTextField bname; /书名private JTextField wname; /作者名private JTextField cbs; /出版社private JTextField num1; /现存量private JTextField num2; /库存量private JButton jbDel;private JTextField jDel;private JButton jbAdd;private JButton jbSearch;private JButton jbUpdate;private JTable table;private JLabel jabel;/输入要查找的书号public JLabel getJabel() if(jabel=null)jabel=new JLabel("查删学号");jabel.setBounds(50, 350, 50, 30);return jabel;public JButton getJbDel() if(jbDel=null)jbDel=new JButton("删除");jbDel.setBounds(180, 400, 60, 30);return jbDel;public JTextField getjDel() if(jDel=null)jDel=new JTextField(20);jDel.setBounds(100, 350, 150, 30);return jDel;public JButton getJbAdd() if(jbAdd=null)jbAdd=new JButton("添加");jbAdd.setBounds(100,400,60,30);return jbAdd;public JButton getJbSearch() if(jbSearch=null)jbSearch=new JButton("查找");jbSearch.setBounds(100, 450, 60, 30);return jbSearch;public JButton getJbUpdate() if(jbUpdate=null)jbUpdate=new JButton("修改");jbUpdate.setBounds(180, 450, 60, 30);return jbUpdate;public JTable getTable() if(table=null)table=new JTable(100,6);table.setBounds(270, 50, 500, 600);return table;public JLabel getLblId() if(lblId=null)lblId=new JLabel("编号");lblId.setBounds(50, 50, 50, 30);return lblId;public JLabel getLblBname() if(lblBname=null)lblBname=new JLabel("书名");lblBname.setBounds(50, 100, 50, 30);return lblBname;public JLabel getLblWname() if(lblWname=null)lblWname=new JLabel("作者");lblWname.setBounds(50,150, 50, 30);return lblWname;public JLabel getLblnum1() if(lblnum1=null)lblnum1=new JLabel("现存量");lblnum1.setBounds(50,200, 50, 30);return lblnum1;public JLabel getLblnum2() if(lblnum2=null)lblnum2=new JLabel("库存量");lblnum2.setBounds(50,250, 50, 30);return lblnum2;public JTextField getbId() if(bId=null)bId=new JTextField(20);bId.setBounds(100, 50,150, 30);return bId;public JTextField getBname() if(bname=null)bname=new JTextField(20);bname.setBounds(100, 100, 150, 30);return bname;public JTextField getWname() if(wname=null)wname=new JTextField(20);wname.setBounds(100, 150, 150, 30);return wname;public JTextField getNum1() if(num1=null)num1=new JTextField(20);num1.setBounds(100, 200, 150, 30);return num1;public JTextField getNum2() if(num2=null)num2=new JTextField(20);num2.setBounds(100, 250, 150, 30);return num2;public JLabel getLblCbs() if(lblCbs=null)lblCbs=new JLabel("出版社");lblCbs.setBounds(50,300, 50, 30);return lblCbs;public JTextField getCbs() if(cbs=null)cbs=new JTextField(20);cbs.setBounds(100, 300, 150, 30);return cbs;public Book(String title)super(title);/JFrame frame=new JFrame();Container cantainer=this.getContentPane();this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);ImageIcon img = new ImageIcon("F:Java传习srcLibraryd50735fae6cd7b8961e8eafd0f2442a7d8330ecc1.jpg");/这是背景图片JLabel imgLabel = new JLabel(img);/将背景图放在标签里。this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE);/注意这里是关键,将背景标签添加到jfram的LayeredPane面板里。imgLabel.setBounds(0,0,img.getIconWidth(), img.getIconHeight();/设置背景标签的位置cantainer.setLayout(new BorderLayout();imgLabel.setLayout(null);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(getJbAdd();imgLabel.add(getJbSearch();imgLabel.add(getJbUpdate();imgLabel.add(getJabel();cantainer.add(imgLabel,BorderLayout.NORTH);(JPanel)cantainer).setOpaque(false); /注意这里,将内容面板设为透明。这样LayeredPane面板中的背景才能显示出来。this.setSize(img.getIconWidth(),img.getIconHeight();myEvent();this.setVisible(true);this.setResizable(true);private void myEvent() / TODO Auto-generated method stubjbAdd.addActionListener(new ActionListener()public void actionPerformed(ActionEvent ee)Connection conn=null;Statement stm=null;String id1=bId.getText();String name1=bname.getText();String name2=wname.getText();String n1=num1.getText();String n2=num2.getText();String chubs=cbs.getText();tryClass.forName("com.mysql.jdbc.Driver");conn=DriverManager.getConnection("jdbc:mysql:/localhost:3306/library","sa","123456");stm=conn.createStatement();String sql="insert into book values('"+id1+"','"+name1+"','"+name2+"','"+n1+"','"+n2+"','"+chubs+"')"stm.executeUpdate(sql);getbId().setText("");getBname().setText("");getWname().setText("");getNum1().setText("");getNum2().setText("");getCbs().setText("");catch(ClassNotFoundException e) catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();finally / 关闭Statement try stm.close(); catch (Exception e) / 关闭Connection try conn.close(); catch (Exception e) );jbDel.addActionListener(new ActionListener()public void actionPerformed(ActionEvent ee)String id=jDel.getText();Connection conn=null;Statement stm=null;tryClass.forName("com.mysql.jdbc.Driver");conn=DriverManager.getConnection("jdbc:mysql:/localhost:3306/library","sa","123456");/String sql="select * from book"String sql="delete from book where Bid='"+id+"'"stm=conn.createStatement();stm.executeUpdate(sql);getjDel().setText("");catch(ClassNotFoundException e) catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();finally / 关闭Statement try stm.close(); catch (Exception e) / 关闭Connection try conn.close(); catch (Exception e) );jbSearch.addActionListener(new ActionListener()public void actionPerformed(ActionEvent ee)String id=jDel.getText();Connection conn=null;Statement stm=null;ResultSet rst=null;tryClass.forName("com.mysql.jdbc.Driver");conn=DriverManager.getConnection("jdbc:mysql:/localhost:3306/library","sa","123456");/String sql="select * from book"String sql="select * from book where Bid='"+id+"'"stm=conn.createStatement();rst=stm.executeQuery(sql);if(rst.next()getbId().setText(rst.getString("Bid");getBname().setText(rst.getString("Bname");getWname().setText(rst.getString("Wname");getNum1().setText(rst.getString("num1");getNum2().setText(rst.getString("num2");getCbs().setText(rst.getString("chubs");getjDel().setText("");catch(ClassNotFoundException e) catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();finally / 关闭Statement try stm.close(); catch (Exception e) / 关闭Connection try conn.close(); catch (Exception e) );jbUpdate.addActionListener(new ActionListener()public void actionPerformed(ActionEvent ee)String id1=bId.getText();String name1=bname.getText();String name2=wname.getText();String n1=num1.getText();String n2=num2.getText();String chubs=cbs.getText();Connection conn=null;Statement stm=null;tryClass.forName("com.mysql.jdbc.Driver");conn=DriverManager.getConnection("jdbc:mysql:/localhost:3306/library","sa","123456");String sql="update library.book set Bname='"+name1+"',Wname='"+name2+"',num1='"+n1+"',num2='"+n2+"',chubs='"+chubs+"' where Bid='"+id1+"'"stm=conn.createStatement();stm.executeUpdate(sql);catch(ClassNotFoundException e) catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();finally / 关闭Statement try stm.close

    注意事项

    本文(Java编写的简单图书管理系统(1).doc)为本站会员(豆****)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开