Java项目:银行管理系统+文档Java基础Gui(java+Gui)

源码获取:博客首页 "资源" 里下载!

功能介绍:

登录、打印、取款、改密、转账、查询、挂失、存款、退卡

 

 

 

 

 

服务模块:

public class atmFrame extends JFrame {

	private JPanel contentPane;
	private user user;
//	private LoginFrame lf;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					atmFrame frame = new atmFrame(null);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}


	/**
	 * Create the frame.
	 */
	public atmFrame(final String name) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 518, 434);
		contentPane = new JPanel();
		setTitle(name);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setLocationRelativeTo(null);
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton queryButton = new JButton("\u67E5\u8BE2");
		queryButton.setBounds(99, 101, 113, 27);
		contentPane.add(queryButton);
		queryButton.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e) {
			user = ExecuteSQL.query(name);
			DecimalFormat df = new DecimalFormat( "0.00 "); 
			JOptionPane.showMessageDialog(null,
		              "您的账户名:"+user.getName()+"\n"+"当前余额:¥"+user.getbalance()+"\n","信息提示",
		              JOptionPane.INFORMATION_MESSAGE);		
		}
		});
		
		JButton depositButton = new JButton("\u5B58\u6B3E");
		depositButton.setBounds(99, 223, 113, 27);
		contentPane.add(depositButton);
		depositButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				depositFrame df = new depositFrame(name);
				setVisible(false);
				df.setVisible(true);
			}
			
		});
		
		JButton withdrawButton = new JButton("\u53D6\u6B3E");
		withdrawButton.setBounds(288, 101, 113, 27);
		contentPane.add(withdrawButton);
		withdrawButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				withdrawFrame wf = new withdrawFrame(name);
				setVisible(false);
				wf.setVisible(true);
			}
			
		});
		
		JButton transferButton = new JButton("\u8F6C\u8D26");
		transferButton.setBounds(288, 223, 113, 27);
		contentPane.add(transferButton);
		transferButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				transferFrame wf = new transferFrame(name);
				setVisible(false);
				wf.setVisible(true);
			}
			
		});
	}

}

登录模块:

public class LoginFrame extends JFrame {

	private JPanel contentPane;
	private JTextField u_name_Field;
	private JPasswordField u_password_field;
	private user user;

	//登录事件监听器
	class loginAction implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			user = ExecuteSQL.check(u_name_Field.getText(), u_password_field.getText());
			if (user.getName() != null) {
				if (user.getPassword().equals(u_password_field.getText())) {
					try {
						atmFrame frame = new atmFrame(user.getName());
						frame.setTitle(user.getName());
						frame.setVisible(true);
						setVisible(false);
					} catch (Exception ex) {
						ex.printStackTrace();
					}
				} else {
					JOptionPane.showMessageDialog(null, "密码不正确!请重新输入");
					u_name_Field.setText("");
					u_password_field.setText("");
				}

			} else {
				JOptionPane.showMessageDialog(null, "找不到该用户,请先注册!");
				u_name_Field.setText("");
				u_password_field.setText("");
			}
		}
	}
	
	//注册事件监听器
	class signAction implements ActionListener{

		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			SignFrame frame = new SignFrame();
			frame.setVisible(true);
			setVisible(false);
		}
		
	}

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					LoginFrame frame = new LoginFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public LoginFrame() {
		setTitle("\u7F51\u4E0A\u94F6\u884C");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 506, 385);
		contentPane = new JPanel();
		setLocationRelativeTo(null);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton LoginButton = new JButton("\u767B\u5F55");
		LoginButton.setFont(new Font("新宋体", Font.BOLD, 20));
		LoginButton.setBounds(92, 214, 120, 37);
		contentPane.add(LoginButton);
		LoginButton.addActionListener(new loginAction());
		
		JButton signButton = new JButton("\u6CE8\u518C");
		signButton.setFont(new Font("新宋体", Font.BOLD, 20));
		signButton.setBounds(283, 214, 113, 37);
		contentPane.add(signButton);
		signButton.addActionListener(new signAction());
		
		JLabel u_nameLabel = new JLabel("\u7528\u6237\u540D\uFF1A");
		u_nameLabel.setFont(new Font("新宋体", Font.BOLD, 18));
		u_nameLabel.setBounds(92, 49, 88, 37);
		contentPane.add(u_nameLabel);
		
		JLabel u_passwordLabel_1 = new JLabel("\u5BC6\u7801\uFF1A");
		u_passwordLabel_1.setFont(new Font("新宋体", Font.BOLD, 18));
		u_passwordLabel_1.setBounds(92, 130, 88, 27);
		contentPane.add(u_passwordLabel_1);
		
		u_name_Field = new JTextField();
		u_name_Field.setBounds(184, 57, 157, 29);
		contentPane.add(u_name_Field);
		u_name_Field.setColumns(10);
		
		u_password_field = new JPasswordField();
		u_password_field.setBounds(184, 133, 157, 27);
		contentPane.add(u_password_field);
		
		JLabel lblNewLabel = new JLabel("\u7528\u6237\u6307\u5357");
		lblNewLabel.setForeground(Color.RED);
		lblNewLabel.setBounds(402, 307, 72, 31);
		contentPane.add(lblNewLabel);
	}
}



收回框设置:

public class withdrawFrame extends JFrame {

	private JPanel contentPane;
	private JTextField outputField;
	private com.shao.model.user user_query;
	private com.shao.model.user user_modMoney;

	/**
	 * Create the frame.
	 */
	public withdrawFrame(final String name) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		setTitle(name);
		setLocationRelativeTo(null);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabe = new JLabel("\u53D6\u6B3E\u91D1\u989D\uFF1A");
		lblNewLabe.setFont(new Font("新宋体", Font.BOLD, 20));
		lblNewLabe.setBounds(84, 75, 117, 38);
		contentPane.add(lblNewLabe);
		
		outputField = new JTextField();
		outputField.setBounds(199, 84, 117, 24);
		contentPane.add(outputField);
		outputField.setColumns(10);
		
		JButton OKButton = new JButton("\u786E\u5B9A");
		OKButton.setFont(new Font("新宋体", Font.BOLD, 15));
		OKButton.setBounds(84, 159, 113, 27);
		contentPane.add(OKButton);
		OKButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				System.out.println("withdrawFrame.withdrawFrame(...).new ActionListener() {...}.actionPerformed()"+outputField.getText());
				if (Float.parseFloat(outputField.getText()) < 100000) {
					if(Float.parseFloat(outputField.getText())%100==0) {
						user_query = ExecuteSQL.query(name);
						if (user_query.getbalance() > Double.parseDouble(outputField.getText())) {
							double temp = user_query.getbalance() - Double.parseDouble(outputField.getText());
							DecimalFormat df = new DecimalFormat( "0.00 ");   
							int i = ExecuteSQL.modifyMoney(name, temp);	
							if(i>0){
								setVisible(false);
								atmFrame frame = new atmFrame(name);
								frame.setVisible(true);
								JOptionPane.showMessageDialog(null, "取钱交易成功!"+"\n" + "剩余余额为:" + df.format(temp));
							}else{
								JOptionPane.showMessageDialog(null, "取钱交易失败!"+"\n" + "剩余余额为:" + df.format(temp));
							}
													
						} else {
							JOptionPane.showMessageDialog(null, "余额不足,请重新输入!" + "\n" + "当前余额为:" + user_query.getbalance());
							outputField.setText("");
						}
					}else {
						JOptionPane.showMessageDialog(null, "系统不支持非100元整钞,请重新输入!");
						outputField.setText("");
					}
					
				} else {
					JOptionPane.showMessageDialog(null, "输入金额大于100000,请重新输入!");
					outputField.setText("");
				}

			}

		});
		
		JButton backButton_1 = new JButton("\u8FD4\u56DE");
		backButton_1.setFont(new Font("新宋体", Font.BOLD, 15));
		backButton_1.setBounds(233, 159, 113, 27);
		contentPane.add(backButton_1);
		backButton_1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				atmFrame af = new atmFrame(name);
				setVisible(false);
				af.setVisible(true);			
			}		
		});
		
		JLabel remindLabel = new JLabel("*\u5355\u7B14\u6700\u5927\u53EF\u53D610000");
		remindLabel.setForeground(Color.RED);
		remindLabel.setBounds(199, 126, 138, 18);
		contentPane.add(remindLabel);
	}

}

源码获取:博客首页 "资源" 里下载!

你可能感兴趣的:(Java毕业设计项目实战篇,java,Gui)