ATM系统实现[3]——余额查询窗口[00原创]

来源:互联网 发布:java 图片合成文字 编辑:程序博客网 时间:2024/06/10 16:50
package cn.edu.ynu.sei.atm.client.ui;

import java.rmi.RemoteException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Text;

/**
 * 余额查询窗口
 * 
@author 88250
 
*/
public class BalanceQueryComposite extends Composite
{
    
/**
     * 返回按钮
     
*/
    
private Button returnBtn = null;

    
/**
     * 提示可取款数标签
     
*/
    
private Label promptAvailableAmountLbl = null;

    
/**
     * 可取款数显示域
     
*/
    
private Text availableAmountText = null;

    
/**
     * 余额显示域
     
*/
    
private Text balanceText = null;

    
/**
     * 提示余额标签
     
*/
    
private Label promptBalanceLbl = null;

    
/**
     * 提示帐户类型标签
     
*/
    
private Label promptAccountTypeLbl = null;

    
/**
     * 帐户类型显示域
     
*/
    
private Text accountTypeText = null;

    
/**
     * 帐户ID显示域
     
*/
    
private Text accountIDText = null;

    
/**
     * 提示帐户ID标签
     
*/
    
private Label promptAccountIDLbl = null;

    
/**
     * 创建余额查询窗口容器
     * 
@param parent 父窗口容器
     
*/
    
public BalanceQueryComposite(Composite parent)
    {
    
super(parent, SWT.NONE);
    createContents();
    }

    
/**
     * 显示帐户相关信息
     
*/
    
public void displayAccountInfo()
    {
    
try
    {
        accountIDText.setText(Integer
            .toString(AccountSelectComposite.account.getID()));
        accountTypeText.setText(AccountSelectComposite.account
            .getAccountType());
        balanceText.setText(Float.toString(AccountSelectComposite.account
            .getBalance()));
        availableAmountText.setText(Float
            .toString(AccountSelectComposite.account.getRemain()));
    }
    
catch (RemoteException re)
    {
        MessageBox exitDlg 
= new MessageBox(this.getShell());
        exitDlg.setText(
"网络连接出现问题....");
        exitDlg.setMessage(
"不能连接到服务器,系统将退出!");
        exitDlg.open();
        System.exit(
0);
        re.printStackTrace();
    }
    
catch (Exception e)
    {
        e.printStackTrace();
    }
    }

    
/**
     * 创建余额查询窗口容器内含控件
     
*/
    
private void createContents()
    {
    promptAccountIDLbl 
= new Label(this, SWT.NONE);
    promptAccountIDLbl.setText(
"帐户ID:");
    promptAccountIDLbl.setBounds(
26205520);

    accountIDText 
= new Text(this, SWT.BORDER);
    accountIDText.setEditable(
false);
    accountIDText.setBounds(
82148025);
    accountTypeText 
= new Text(this, SWT.BORDER);
    accountTypeText.setEditable(
false);
    accountTypeText.setBounds(
82468025);

    promptAccountTypeLbl 
= new Label(this, SWT.NONE);
    promptAccountTypeLbl.setText(
"帐户类型:");
    promptAccountTypeLbl.setBounds(
14516520);

    promptBalanceLbl 
= new Label(this, SWT.NONE);
    promptBalanceLbl.setText(
"当前余额:");
    promptBalanceLbl.setBounds(
15866520);

    balanceText 
= new Text(this, SWT.BORDER);
    balanceText.setEditable(
false);
    balanceText.setBounds(
83828025);

    availableAmountText 
= new Text(this, SWT.BORDER);
    availableAmountText.setEditable(
false);
    availableAmountText.setBounds(
831188025);

    promptAvailableAmountLbl 
= new Label(this, SWT.NONE);
    promptAvailableAmountLbl.setText(
"可取款数:");
    promptAvailableAmountLbl.setBounds(
171226520);

    returnBtn 
= new Button(this, SWT.BORDER);
    returnBtn.setText(
"返回");
    returnBtn.setBounds(
1241544030);
    }

    
/**
     * 取得返回按钮
     * 
@return 返回按钮
     
*/
    
public Button getReturnLbl()
    {
    
return returnBtn;
    }

    @Override
    
public void dispose()
    {
    
super.dispose();
    }

    @Override
    
protected void checkSubclass()
    {
    
// Disable the check that prevents subclassing of SWT components
    }

}
 
原创粉丝点击