package com.atm.view;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Image;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableColumnModelEvent;
import javax.swing.event.TableColumnModelListener;
import com.atm.dao.AdminDAOImp;
import com.atm.service.AdminService;
import com.atm.service.AdminDialogService.AddUserDialog;
import com.atm.service.AdminDialogService.EditUserInfoDialog;
import com.atm.service.AdminDialogService.SearchUserByIdDialog;
import com.atm.service.AdminDialogService.SeeUserInfoDialog;
public class ATMAdminFrame extends JFrame implements ActionListener,ListSelectionListener,TableColumnModelListener{
//创建用于装表格的滚动窗格
private JScrollPane jsp=new JScrollPane();
//记录行与列的成员变量
private int row;//行
private int col;//列
//显示账户的表格
private JTable table=new JTable();
//窗口底部信息显示标签和用于布局的JPanel
private JPanel bottomPanel=new JPanel();
private JLabel bottomNewsOneLabel=new JLabel("账户总计:");
private JLabel bottomNewsTwoLabel=new JLabel("版权所有,盗版必究!");
//创建服务类
private AdminService adminService=new AdminService();
//创建查看用户信息按钮
private JButton seeUserInfoButton=new JButton("查看",new ImageIcon("F:\\MyEclipse\\abcdefg\\atm\\source\\see.gif"));
//创建全选按钮
private JButton selectAllButton=new JButton("全选",new ImageIcon("F:\\MyEclipse\\abcdefg\\atm\\source\\select_all.gif"));
//创建添加按钮
private JButton addButton=new JButton("增加",new ImageIcon("F:\\MyEclipse\\abcdefg\\atm\\source\\add.gif"));
//创建编辑按钮
private JButton editButton=new JButton("更改",new ImageIcon("F:\\MyEclipse\\abcdefg\\atm\\source\\edit.gif"));
//创建删除按钮
private JButton deleteButton=new JButton("删除",new ImageIcon("F:\\MyEclipse\\abcdefg\\atm\\source\\delete.gif"));
//创建查看所有按钮
private JButton seeAllButton=new JButton("所有",new ImageIcon("F:\\MyEclipse\\abcdefg\\atm\\source\\see_all.gif"));
//创建查找按钮
private JButton searchButton=new JButton("查找",new ImageIcon("F:\\MyEclipse\\abcdefg\\atm\\source\\search.gif"));
//创建工具栏
private JToolBar toolBar=new JToolBar("菜单条",JToolBar.HORIZONTAL);
private JPanel panel=new JPanel();
public ATMAdminFrame(){
//设置窗口、工具栏的属性
this.setTitle("银行账户管理系统");
this.setLayout(null);
this.setBounds(50, 40,(int)this.getToolkit().getScreenSize().getWidth()-100,(int)this.getToolkit().getScreenSize().getHeight()-100);
Image icon=this.getToolkit().getImage("F:\\MyEclipse\\abcdefg\\atm\\source\\icon.png");
this.setIconImage(icon);
toolBar.setFloatable(false);
toolBar.setBounds(0, 0, 1024, 60);
//设置窗口底部面板、标签的属性的属性
bottomPanel.setLayout(new BorderLayout());
bottomPanel.setBackground(new Color(175,207,203,160));
bottomPanel.setBounds(0, (int)this.getToolkit().getScreenSize().getHeight()-180, (int)this.getToolkit().getScreenSize().getWidth()-100, 60);
bottomPanel.add(bottomNewsOneLabel,BorderLayout.WEST);
bottomPanel.add(bottomNewsTwoLabel,BorderLayout.EAST);
//为按钮设置背景色
seeUserInfoButton.setBackground(new Color(175,207,203,150));
selectAllButton.setBackground(new Color(175,207,203,150));
addButton.setBackground(new Color(175,207,203,150));
editButton.setBackground(new Color(175,207,203,150));
deleteButton.setBackground(new Color(175,207,203,150));
seeAllButton.setBackground(new Color(175,207,203,150));
searchButton.setBackground(new Color(175,207,203,150));
//为表格选择模型和列模型注册监听器
// table.createDefaultColumnsFromModel();
// table.getSelectionModel().addListSelectionListener(this);
// table.getColumnModel().addColumnModelListener(this);
//为按钮注册监听器
seeUserInfoButton.addActionListener(this);
selectAllButton.addActionListener(this);
addButton.addActionListener(this);
editButton.addActionListener(this);
deleteButton.addActionListener(this);
seeAllButton.addActionListener(this);
searchButton.addActionListener(this);
//为某些按钮设置其他属性
seeUserInfoButton.setEnabled(false);
selectAllButton.setEnabled(false);
editButton.setEnabled(false);
deleteButton.setEnabled(false);
//为按钮设置工具提示信息
seeUserInfoButton.setToolTipText("查看所选账户详细信息");
selectAllButton.setToolTipText("全选");
addButton.setToolTipText("添加账户");
editButton.setToolTipText("更改账户信息");
deleteButton.setToolTipText("删除账户");
seeAllButton.setToolTipText("查看所有账户");
searchButton.setToolTipText("按账号查找用户");
//向工具栏中添加按钮
toolBar.add(seeAllButton);
toolBar.add(seeUserInfoButton);
toolBar.add(addButton);
toolBar.add(deleteButton);
toolBar.add(editButton);
toolBar.add(selectAllButton);
toolBar.add(searchButton);
//将工具栏添加到窗口中
this.add(toolBar);
this.add(bottomPanel);
this.add(jsp);
//为窗口添加监听器
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
this.setResizable(true);
this.validate();
this.setVisible(true);;
}
/*
* 实现ActionListener中的方法,实现事件处理
*/
public void actionPerformed(ActionEvent e) {
//查看所有
if(e.getSource()==seeAllButton){
this.table=adminService.getTable();
this.table.createDefaultColumnsFromModel();
this.table.getSelectionModel().addListSelectionListener(this);
this.table.getColumnModel().addColumnModelListener(this);
jsp.removeAll();
this.remove(this.jsp);
JScrollPane jsp=new JScrollPane(table);
this.jsp=jsp;
this.jsp.setBounds(0, 62,(int)this.getToolkit().getScreenSize().getWidth()-110,(int)this.getToolkit().getScreenSize().getHeight()-230);
this.add(jsp);
bottomNewsOneLabel.setText("账户总计:"+this.table.getRowCount());
this.validate();
selectAllButton.setEnabled(true);
}
//查看某一用户详细信息
else if(e.getSource()==seeUserInfoButton){
int row=this.table.getSelectedRow();
String id=(String)table.getValueAt(row,1);
new SeeUserInfoDialog(this,id).setVisible(true);
}
//添加账户
else if(e.getSource()==addButton){
new AddUserDialog(this).setVisible(true);
}
//删除账户
else if(e.getSource()==deleteButton){
int yesOrNo=JOptionPane.NO_OPTION;//用于记录管理者在删除对话框中的选择
int row=this.table.getSelectedRow();
String id=(String)table.getValueAt(row,1);
// System.out.println("row="+row);
// System.out.println("id="+table.getValueAt(row,1));
yesOrNo=JOptionPane.showConfirmDialog(this, "删除将永远不可恢复!确定删除?", "确认",JOptionPane.YES_NO_OPTION);
if(JOptionPane.YES_OPTION==yesOrNo){
AdminDAOImp deleteByIdDao=new AdminDAOImp();
boolean success=deleteByIdDao.deleteById(id);
if(success==true){
this.table=adminService.getTable();
this.table.createDefaultColumnsFromModel();
this.table.getSelectionModel().addListSelectionListener(this);
this.table.getColumnModel().addColumnModelListener(this);
jsp.removeAll();
this.remove(this.jsp);
JScrollPane jsp=new JScrollPane(table);
this.jsp=jsp;
this.jsp.setBounds(0, 62,(int)this.getToolkit().getScreenSize().getWidth()-110,(int)this.getToolkit().getScreenSize().getHeight()-230);
this.add(jsp);
bottomNewsOneLabel.setText("账户总计:"+this.table.getRowCount());
this.validate();
selectAllButton.setEnabled(true);
JOptionPane.showMessageDialog(this, "删除成功", "结果",JOptionPane.INFORMATION_MESSAGE);
}
else{
JOptionPane.showMessageDialog(this, "删除失败", "结果",JOptionPane.WARNING_MESSAGE);
}
}
}
//更改用户信息
else if(e.getSource()==editButton){
int row=this.table.getSelectedRow();
String id=(String)table.getValueAt(
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一、 课程设计名称及内容 名称:自动取款机模拟程序 内容:在PC机上设计一个自动取款机的模拟程序,实现现实中取款机的大部分功能。 二、任务和要求 1. 程序分为两部分:管理端和客户端。 2. 管理端负责管理所有的银行卡,管理员(省略身份验证)可以增加和删除银行卡。 (1) 每张银行卡由卡号唯一标识,卡号由12位阿拉伯数字组成; (2) 新增的银行卡密码均为“123456”,卡内金额均为0元; (3) 只有管理员增加的银行卡才能登陆客户端; (4) 删除后的银行卡将不能再登陆客户端。 3. 客户端负责常见的取款机操作。 (1) 客户端需要登陆,用户输入正确的银行卡号和密码,系统核对无误后才能进行操作; (2) 登陆后,用户可以进行查询余额、取款、存款和修改密码的操作; (3) 修改密码时,用户需输入两次新密码,确定无误后方可更改; (4) 取款和存款操作,有操作结果提示,如“操作成功”或“余额不足,操作失败”等。 4. 界面尽可能模仿自动取款机的实际界面。 5. 对于失败操作,尽可能采用异常捕捉的机制来完成。
资源推荐
资源详情
资源评论
收起资源包目录
Java课程设计—自动取款机模拟程序.rar (87个子文件)
atm
.project 379B
bin
com
atm
dao
AdminDAOImp.class 5KB
DBManager.class 1KB
ClientDAOImp.class 3KB
view
ATMClientFrame.class 5KB
DemandResultFrame.class 3KB
GetCashFrame.class 4KB
ATMAdminFrame.class 8KB
ATMAdminFrame$1.class 704B
SavingFrame.class 3KB
ChangePasswordFrame.class 4KB
Main.class 429B
ATMClientFrame$1.class 710B
ClientIndexFrame.class 4KB
exception
InputChangePasswordInfoNotRightException.class 579B
AddUserInfoHaveErrorException.class 546B
InputSavingNumNotRightException.class 543B
InputGetCashNumNotRightException.class 555B
InputIdOrPasswordWrongException.class 543B
InputInfoFormatNotRightException.class 555B
interfaceDao
AdminDAO.class 355B
ClientDAO.class 279B
service
AddUserService.class 2KB
ChangePasswordService.class 2KB
AdminService.class 1KB
AdminSearchService.class 1KB
SavingService.class 1KB
AdminDialogService
SearchUserByIdDialog$1.class 866B
SearchUserByIdDialog.class 5KB
EditUserInfoDialog.class 9KB
AddUserDialog.class 8KB
SeeUserInfoDialog.class 5KB
GetCashService.class 1KB
LoginService.class 2KB
entity
ChangePasswordBean.class 1KB
ClientBean.class 962B
ManagerBean.class 748B
ClientInfoBean.class 3KB
source
delete.gif 2KB
search.gif 2KB
edit.gif 2KB
add.gif 1KB
select_all.gif 2KB
Thumbs.db 21KB
see.gif 2KB
see_all.gif 2KB
icon.png 26KB
src
com
atm
dao
AdminDAOImp.java 5KB
DBManager.java 864B
ClientDAOImp.java 3KB
view
Main.java 207B
ChangePasswordFrame.java 5KB
DemandResultFrame.java 2KB
LoginFrame.java 4KB
SavingFrame.java 3KB
GetCashFrame.java 3KB
ClientIndexFrame.java 4KB
ATMClientFrame.java 4KB
ATMAdminFrame.java 9KB
exception
InputChangePasswordInfoNotRightException.java 304B
InputSavingNumNotRightException.java 286B
AddUserInfoHaveErrorException.java 282B
InputIdOrPasswordWrongException.java 281B
InputInfoFormatNotRightException.java 288B
InputGetCashNumNotRightException.java 359B
interfaceDao
ClientDAO.java 383B
AdminDAO.java 506B
service
ChangePasswordService.java 2KB
SavingService.java 887B
LoginService.java 2KB
AdminDialogService
SeeUserInfoDialog.java 5KB
EditUserInfoDialog.java 9KB
SearchUserByIdDialog.java 4KB
AddUserDialog.java 8KB
AdminService.java 814B
AddUserService.java 1KB
GetCashService.java 1KB
AdminSearchService.java 1KB
entity
ManagerBean.java 413B
RemoveInfoBean.java 575B
ChangePasswordBean.java 943B
ClientBean.java 569B
ClientInfoBean.java 2KB
.classpath 313B
课程设计报告.doc 261KB
atm_Data.MDF 1024KB
atm_Log.LDF 1024KB
共 87 条
- 1
资源评论
- wupeng08092013-06-08分太贵了,这么简单的东西
- guoxin524162013-07-05还好吧 就是分有一点贵
wangyijiangshui
- 粉丝: 8
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功