【Java开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了Java开源代码-EventHandle.java的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
/*
* Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. U.S.
* Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and
* applicable provisions of the FAR and its supplements. Use is subject
* to license terms.
*
* This distribution may include materials developed by third parties.
* Sun, Sun Microsystems, the Sun logo, Java and J2EE are trademarks
* or registered trademarks of Sun Microsystems, Inc. in the U.S. and
* other countries.
*
* Copyright (c) 2006 Sun Microsystems, Inc. Tous droits reserves.
*
* Droits du gouvernement americain, utilisateurs gouvernementaux - logiciel
* commercial. Les utilisateurs gouvernementaux sont soumis au contrat de
* licence standard de Sun Microsystems, Inc., ainsi qu'aux dispositions
* en vigueur de la FAR (Federal Acquisition Regulations) et des
* supplements a celles-ci. Distribue par des licences qui en
* restreignent l'utilisation.
*
* Cette distribution peut comprendre des composants developpes par des
* tierces parties. Sun, Sun Microsystems, le logo Sun, Java et J2EE
* sont des marques de fabrique ou des marques deposees de Sun
* Microsystems, Inc. aux Etats-Unis et dans d'autres pays.
*/
package com.sun.ebank.appclient;
import java.util.ResourceBundle;
import java.util.ResourceBundle;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Date;
public class EventHandle implements ActionListener {
private static BankAdmin frame;
private ResourceBundle messages = null;
private DataModel dataModel;
private String returned;
private int currentFunction;
public EventHandle(BankAdmin frame, ResourceBundle messages) {
this.frame = frame;
this.messages = messages;
this.dataModel = new DataModel(frame, messages);
//Hook up action events
hookupEvents();
}
//Respond to radio button and return key action events
public void actionPerformed(ActionEvent event) {
//Set Account description according to radio buttons
if (event.getActionCommand() == "savingsstring") {
frame.setDescription("Savings");
}
if (event.getActionCommand() == "checkingstring") {
frame.setDescription("Checking");
}
if (event.getActionCommand() == "creditstring") {
frame.setDescription("Credit");
}
if (event.getActionCommand() == "mnymktstring") {
frame.setDescription("Money Market");
}
//Set balance to beginning balance for new accounts
//when return key pressed in begining balance field
Object source = event.getSource();
if (source == frame.begbal) {
String begbalstring = frame.begbal.getText();
frame.bal.setText(begbalstring);
}
}
private void setDisplay() {
frame.p2.setBackground(Color.white);
frame.spacerlab1.setText("");
frame.spacerlab2.setText("");
}
private void hookupEvents() {
//View Customer Information
frame.viewcust.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
setDisplay();
frame.clearMessages();
String vitem = messages.getString("ViewCust");
frame.messlab6.setText(vitem);
String mess =
new String(messages.getString("EnterCustIDMess"));
returned = JOptionPane.showInputDialog(frame, mess);
if (returned != null) {
currentFunction = 3;
dataModel.createCustInf(currentFunction, returned);
}
}
});
//Create New Customer
frame.createcust.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
setDisplay();
frame.clearMessages();
String citem = messages.getString("CreateCust");
frame.messlab6.setText(citem);
currentFunction = 1;
dataModel.createCustInf(currentFunction, returned);
}
});
//Update Customer Information
frame.updatecust.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
setDisplay();
frame.clearMessages();
String uitem = messages.getString("UpdateCust");
frame.messlab6.setText(uitem);
String mess =
new String(messages.getString("EnterCustIDMess"));
returned = JOptionPane.showInputDialog(frame, mess);
if (returned != null) {
currentFunction = 2;
dataModel.createCustInf(currentFunction, returned);
}
}
});
//View Account Information
frame.viewact.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
setDisplay();
frame.clearMessages();
String vitem = messages.getString("ViewAct");
frame.messlab6.setText(vitem);
String mess =
new String(messages.getString("EnterActIDMess"));
returned = JOptionPane.showInputDialog(frame, mess);
if (returned != null) {
currentFunction = 4;
dataModel.createActInf(currentFunction, returned);
}
}
});
//Create New Account
frame.createact.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
setDisplay();
frame.clearMessages();
String citem = messages.getString("CreateAct");
frame.messlab6.setText(citem);
currentFunction = 5;
dataModel.createActInf(currentFunction, returned);
}
});
//Add Customer to Account
frame.addcust.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
setDisplay();
frame.clearMessages();
String aitem = messages.getString("AddCust");
frame.messlab6.setText(aitem);
currentFunction = 6;
frame.addCustToActFields(null, null);
}
});
//Remove Account
frame.remact.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
setDisplay();
frame.clearMessages();
String ritem = messages.getString("RemAct");
frame.messlab6.setText(ritem);
String mess =
new String(messages.getString("EnterActIDMess"));
returned = JOptionPane.showInputDialog(frame, mess);
if (returned != null) {
currentFunction = 7;
dataModel.removeAccount(returned);
}
}
});
//Search for Customer ID by last name
frame.srchcust.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
setDisplay();
frame.clearMessages();
String sitem = messages.getString("SearchCust");
frame.messlab6.setText(sitem);
String mess =
new String(messages.getString("EnterLastNameMess"));
returned = JOptionPane.showInputDia
上一篇:
EventEx3.java
下一篇:
谈初中数学“一元二次方程”的几种常见题型