java开发图书管理系统,用文件存储数据.doc
《java开发图书管理系统,用文件存储数据.doc》由会员分享,可在线阅读,更多相关《java开发图书管理系统,用文件存储数据.doc(36页珍藏版)》请在三一办公上搜索。
1、一:注册界面及代码:/* * 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.Act
2、ionListener;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.
3、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=取消;f
4、inal 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 JPasswor
5、dField txtPasswordOK;/此密码框用于用户输入确认密码private JButton btnCommit;/按钮用于提交注册信息private JButton btnCancel;/按钮用于取消/用户列表public Vector stVector=new Vector();/窗体高宽设定final int WIDTH=600;final int HEIGHT=400;/RegisteFrame初始化SuppressWarnings(unchecked)public RegisteFrame(Object obj,String title)super(title);/设置窗体
6、标题stVector =(Vector)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,
7、 (screenSize.height - frameSize.height) / 2);init();/初始化/窗体初始化:增加控件public void init()/网格布局:32getContentPane().setLayout(new GridLayout(ROW,COL);/创建相应的控件lblUserName=new JLabel(USERNAME);txtUserName=new JTextField();lblPassword=new JLabel(PASSWORD);txtPassword=new JPasswordField();lblPasswordOK=new JL
8、abel(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
9、(BevelBorder.LOWERED);/用户名文本本框边框lblPassword.setHorizontalAlignment(0);/密码文字居中显示lblPassword.setBorder(new CompoundBorder(null, new BevelBorder(BevelBorder.RAISED);/显示口令:标签边框设置txtPassword.setBorder(new BevelBorder(BevelBorder.LOWERED);/密码框边框lblPasswordOK.setHorizontalAlignment(0);/确认密码居中显示lblPasswordO
10、K.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().tri
11、m();/获取用户输入用户名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=a&ch=0&ch=9)flag=true;elseflag=false;if(flag)if(pareTo(passwordOK)
12、!=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_MESS
13、AGE ); dispose(); LogonFrame logon =new LogonFrame(stVector,用户登录); logon.setVisible(true);else/注册失败 JOptionPane.showMessageDialog( null, 用户名不符合要求,请输入只有rn英文字母和数字组成的字符串。, 注册失败, JOptionPane.INFORMATION_MESSAGE ););/取消按钮btnCancel.addActionListener(new ActionListener() public void actionPerformed(ActionE
14、vent 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(btnCo
15、mmit);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 */pa
16、ckage 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.J
17、Frame;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 ext
18、ends 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 l
19、blPassword;/此标签用于显示密码private JTextField txtUserName;/此文本框用于用户输入登录用户名private JPasswordField txtPassword;/此密码框用于用户输入登录密码private JButton btnOK;/按钮用于登录private JButton btnCancel;/按钮用于取消private JCheckBox chkMpwd;/记住密码private JCheckBox chkAotuLogon;/自动登录/用户列表public Vector stVector;/窗体高宽设定final int WIDTH=60
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 开发 图书 管理 系统 文件 存储 数据
链接地址:https://www.31ppt.com/p-2392090.html