欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOC文档下载  

    java开发图书管理系统,用文件存储数据.doc

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

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

    java开发图书管理系统,用文件存储数据.doc

    一:注册界面及代码:/* * BigHomeworkcs2011z.libraryRegisteFrame.javaRegisteFrame苏州科技学院,计算机Z1111,徐磊2013-11-13下午6:39:12 */package cs2011z.library;/* * author Administrator * */import java.awt.Dimension;import java.awt.GridLayout;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Vector;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;import javax.swing.border.BevelBorder;import javax.swing.border.CompoundBorder;/* * author Administrator * RegisteFrame */public class RegisteFrame extends JFrame/* * 注册界面 */private static final long serialVersionUID = 1L;/控件显示文件信息final String USERNAME="用 户 名:"final String PASSWORD="密 码:"final String PASSWORDOK="确认密码:"final String COMMIT="提交"final String CANCEL="取消"final String NULL=""/网格布局行、列final int ROW=4;/行final int COL=2;/列/窗体控件定义private JLabel lblUserName;/此标签用于显示"用户名"private JLabel lblPassword;/此标签用于显示"密码"private JLabel lblPasswordOK;/此标签用于显示"确认密码"private JTextField txtUserName;/此文本框用于用户输入注册的用户名private JPasswordField txtPassword;/此密码框用于用户输入注册密码 private JPasswordField txtPasswordOK;/此密码框用于用户输入确认密码private JButton btnCommit;/按钮用于提交注册信息private JButton btnCancel;/按钮用于取消/用户列表public Vector<User> stVector=new Vector<User>();/窗体高宽设定final int WIDTH=600;final int HEIGHT=400;/RegisteFrame初始化SuppressWarnings("unchecked")public RegisteFrame(Object obj,String title)super(title);/设置窗体标题stVector =(Vector<User>)obj;/userVecsetSize(WIDTH,HEIGHT);/窗体显示大小设置setVisible(true);setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);/窗体关闭Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = this.getSize(); this.setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);init();/初始化/窗体初始化:增加控件public void init()/网格布局:3×2getContentPane().setLayout(new GridLayout(ROW,COL);/创建相应的控件lblUserName=new JLabel(USERNAME);txtUserName=new JTextField();lblPassword=new JLabel(PASSWORD);txtPassword=new JPasswordField();lblPasswordOK=new JLabel(PASSWORDOK);txtPasswordOK=new JPasswordField();btnCommit =new JButton(COMMIT);btnCancel =new JButton(CANCEL);/设置控件属性lblUserName.setHorizontalAlignment(0);/"用户名"居中显示lblUserName.setBorder(new CompoundBorder(null, new BevelBorder(BevelBorder.RAISED);/显示"用户名:"标签边框设置txtUserName.setBorder(new BevelBorder(BevelBorder.LOWERED);/用户名文本本框边框lblPassword.setHorizontalAlignment(0);/"密码"文字居中显示lblPassword.setBorder(new CompoundBorder(null, new BevelBorder(BevelBorder.RAISED);/显示"口令:"标签边框设置txtPassword.setBorder(new BevelBorder(BevelBorder.LOWERED);/密码框边框lblPasswordOK.setHorizontalAlignment(0);/"确认密码"居中显示lblPasswordOK.setBorder(new CompoundBorder(null, new BevelBorder(BevelBorder.RAISED);/显示"确认密码:"标签边框设置txtPasswordOK.setBorder(new BevelBorder(BevelBorder.LOWERED);/确认密码框边框/增加监听器/确定按钮btnCommit.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e)String username=txtUserName.getText().trim();/获取用户输入用户名String password=new String(txtPassword.getPassword().trim();/获取户输入的密码String passwordOK=new String(txtPasswordOK.getPassword().trim();boolean flag=true;char userName=username.toCharArray();for(char ch:userName)if(ch>='A'&&ch<='Z'|ch>='a'&&ch<='z'|ch>='0'&&ch<='9')flag=true;elseflag=false;if(flag)if(pareTo(passwordOK)!=0)/注册失败 JOptionPane.showMessageDialog( null, "两次密码不一致!", "注册失败", JOptionPane.INFORMATION_MESSAGE );elseUser userRegiste=new User(username,password);/创建一个用户对象stVector.add(userRegiste);/obj.add();/注册成功 JOptionPane.showMessageDialog( null, "用户名:"+username+"rn"+"密码:"+password, "注册成功", JOptionPane.INFORMATION_MESSAGE ); dispose(); LogonFrame logon =new LogonFrame(stVector,"用户登录"); logon.setVisible(true);else/注册失败 JOptionPane.showMessageDialog( null, "用户名不符合要求,请输入只有rn英文字母和数字组成的字符串。", "注册失败", JOptionPane.INFORMATION_MESSAGE ););/取消按钮btnCancel.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) dispose(););/增加相应控件getContentPane().add(lblUserName);getContentPane().add(txtUserName);getContentPane().add(lblPassword);getContentPane().add(txtPassword);getContentPane().add(lblPasswordOK);getContentPane().add(txtPasswordOK);JPanel jp1 = new JPanel();JPanel jp2 = new JPanel();jp1.add(btnCommit);jp2.add(btnCancel);getContentPane().add(jp1);getContentPane().add(jp2);public static void main(String args)RegisteFrame frame =new RegisteFrame(new Vector(),"用户注册");frame.setVisible(true);二:登录界面及代码。/* * BigHomeworkcs2011z.libraryLogonFrame.javaLogonFrame苏州科技学院,计算机Z1111,徐磊2013-11-15下午6:40:25 */package cs2011z.library;/* * author Administrator * */import java.awt.Dimension;import java.awt.GridLayout;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Vector;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;import javax.swing.border.BevelBorder;import javax.swing.border.CompoundBorder;/* * author Administrator * LogonFrame */public class LogonFrame extends JFrame/* * 登录控件 */private static final long serialVersionUID = 1L;/控件显示文件信息final String USERNAME="用户名:"final String PASSWORD="密 码:"final String OK="确定"final String CANCEL="取消"final String NULL=""/网格布局行、列final int ROW=4;/行final int COL=2;/列/窗体控件定义private JLabel lblUserName;/此标签用于显示"用户名"private JLabel lblPassword;/此标签用于显示"密码"private JTextField txtUserName;/此文本框用于用户输入登录用户名private JPasswordField txtPassword;/此密码框用于用户输入登录密码private JButton btnOK;/按钮用于登录private JButton btnCancel;/按钮用于取消private JCheckBox chkMpwd;/记住密码private JCheckBox chkAotuLogon;/自动登录/用户列表public Vector<User> stVector;/窗体高宽设定final int WIDTH=600;final int HEIGHT=400;/LogonFrame初始化SuppressWarnings("unchecked")public LogonFrame(Object obj,String title)super(title);/设置窗体标题stVector =(Vector<User>)obj;setSize(WIDTH,HEIGHT);/窗体显示大小设置setVisible(true);setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);/窗体关闭Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = this.getSize(); this.setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);init();/初始化/窗体初始化:增加控件public void init()/网格布局:3×2getContentPane().setLayout(new GridLayout(ROW,COL);/创建相应的控件lblUserName=new JLabel(USERNAME);txtUserName=new JTextField();lblPassword=new JLabel(PASSWORD);txtPassword=new JPasswordField();btnOK =new JButton(OK);btnCancel =new JButton(CANCEL);chkMpwd =new JCheckBox("记住密码");chkAotuLogon=new JCheckBox("自动登录");/设置控件属性lblUserName.setHorizontalAlignment(0);/"用户名"居中显示lblUserName.setBorder(new CompoundBorder(null, new BevelBorder(BevelBorder.RAISED);/显示"用户名:"标签边框设置txtUserName.setBorder(new BevelBorder(BevelBorder.LOWERED);/用户名文本本框边框lblPassword.setHorizontalAlignment(0);/"密码"居中显示lblPassword.setBorder(new CompoundBorder(null, new BevelBorder(BevelBorder.RAISED);/显示"密码:"标签边框设置txtPassword.setBorder(new BevelBorder(BevelBorder.LOWERED);/密码框边框chkMpwd.setHorizontalAlignment(0);chkAotuLogon.setHorizontalAlignment(0);/增加监听器/确定按钮btnOK.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e)String username=txtUserName.getText().trim();/获取用户输入用户名String password=new String(txtPassword.getPassword().trim();/获取户输入的密码User userLogon=new User(username,password);/创建一个用户对象boolean flag=false;/存在标记/用循环查询用户名和密码是否存在for(User user:stVector)/if(user.equals(userLogon)if(user.getUserName().trim().compareTo(userLogon.getUserName().trim()=0&&user.getPassword().trim().compareTo(userLogon.getPassword().trim()=0)flag=true; if(flag) /登录成功 JOptionPane.showMessageDialog( null, "用户名:"+userLogon.getUserName()+"rn用户登录成功!", "登录成功", JOptionPane.INFORMATION_MESSAGE ); dispose(); AllLayoutDemo demo =new AllLayoutDemo(); demo.setLayout(); demo.setVisible(true); else /登录失败 JOptionPane.showMessageDialog( null, "用户名或口令错!请重新输入!",/提示信息 "登录失败",/提示信息 JOptionPane.INFORMATION_MESSAGE ); txtUserName.setText(NULL);/用户名文本框设置为空 txtPassword.setText(NULL);/口令密码框设置为空 txtUserName.setFocusable(true);/使其获得焦点 );/取消按钮btnCancel.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) dispose(););/增加相应控件getContentPane().add(lblUserName);getContentPane().add(txtUserName);getContentPane().add(lblPassword);getContentPane().add(txtPassword);getContentPane().add(chkMpwd);getContentPane().add(chkAotuLogon);JPanel jp1 = new JPanel();JPanel jp2 = new JPanel();jp1.add(btnOK);jp2.add(btnCancel);getContentPane().add(jp1);getContentPane().add(jp2);public static void main(String args)Vector<User> stVector=new Vector<User> ();stVector.add(0,new User("admin","123456");stVector.add(0,new User("xl","123456");stVector.add(1,new User("Tom","123456");stVector.add(2,new User("Jack","123456");stVector.add(3,new User("David","123456");LogonFrame frame = new LogonFrame(stVector,"用户登录");frame.setVisible(true);三:登录主界面及代码。/* * cs2011z.library苏州科技学院,计算机Z1111.徐磊2013年11月5日AllLayoutDemo.java */package cs2011z.library;/* * author Administrator * */import javax.swing.*;import javax.swing.event.*;import java.awt.*;import java.awt.event.*;import java.util.*;public class AllLayoutDemo extends JFrame implements ActionListener/创建控件private JTextArea taCollect;private JLabel text = new JLabel("图书详细信息");private JLabel text1 = new JLabel("排序后结果输出");private JMenuBar jmb = new JMenuBar();private JMenu helpmenu = new JMenu("帮助");private JMenu listmenu = new JMenu("排序");private JMenu datamenu = new JMenu("数据操作");/private JButton btnSearch = new JButton("查找数据");private JButton btnInsert = new JButton("插入数据");private JButton btnDelete = new JButton("删除数据");/private Container container = getContentPane();private BookData list = new BookData1000;private DataOperate op = new DataOperate();private String lib = new String1000;private int date = new int 10004;private JMenuItem exitItem = new JMenuItem("退出", 'T');private JMenuItem helpItem = new JMenuItem("帮助", 'H');private JMenuItem numlistItem = new JMenuItem("按图书号排序", 'N');private JMenuItem InsertItem = new JMenuItem("插入数据",'I');private JMenuItem SearchItem = new JMenuItem("查找数据",'S');private JMenuItem DeleteItem = new JMenuItem("删除数据",'D');private JMenuItem ChangeItem = new JMenuItem("修改数据",'C');JList Book;/无参构造函数,实现对图形界面的初始化public AllLayoutDemo()super("图书管理信息系统");this.setSize(600,750);this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);/主方法/public static void main(String args)/AllLayoutDemo frame = new AllLayoutDemo();/frame.setLayout();/frame.show();/布局设计public void setLayout()DataOperate op = new DataOperate();op.readDatabase();String string;String lib = new String1000;JList Book = new JList(lib);container.setLayout(null);container.add(text);text.setBounds(220,10,200,25);for(int i = 1;i <= op.getBookCount();i+)listi = op.r(i);string = "图书号:" + listi.number + " 图书名:" + listi.name +" 作者:"+listi.author+" 图书价格:"+listi.price+ " 到馆时间:" + listi.ltime + " 借出时间:" + listi.otime;libi = string; / JScrollPane myScrollPane=new JScrollPane();myScrollPane.setBounds(10,40,570,360); container.add(Book);myScrollPane.getViewport().add(Book,null);this.getContentPane().add(myScrollPane);Book.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);this.setJMenuBar(jmb);jmb.add(datamenu);jmb.add(listmenu);jmb.add(helpmenu);datamenu.add(InsertItem);datamenu.add(DeleteItem);datamenu.add(SearchItem);datamenu.add(ChangeItem);ChangeItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK);InsertItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK);DeleteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK);SearchItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK);/创建事件监听器InsertItem.addActionListener(this);DeleteItem.addActionListener(this);SearchItem.addActionListener(this);ChangeItem.addActionListener(this);listmenu.add(numlistItem);numlistItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK);numlistItem.addActionListener(this);

    注意事项

    本文(java开发图书管理系统,用文件存储数据.doc)为本站会员(laozhun)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

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




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开