Methods Summary |
---|
private javax.swing.JPanel | buildActionPanel()
JPanel actionPanel = new JPanel(new GridLayout(3, 3));
actionPanel.add(new JLabel("Account Name:"));
_accountNameField = new JTextField();
actionPanel.add(_accountNameField);
JButton getBalanceButton = new JButton("Get Balance");
getBalanceButton.addActionListener(new GetBalanceAction());
actionPanel.add(getBalanceButton);
actionPanel.add(new JLabel("Withdraw"));
_withdrawalTextField = new JTextField();
actionPanel.add(_withdrawalTextField);
JButton withdrawalButton = new JButton("Do it");
withdrawalButton.addActionListener(new WithdrawAction());
actionPanel.add(withdrawalButton);
actionPanel.add(new JLabel("Deposit"));
_depositTextField = new JTextField();
actionPanel.add(_depositTextField);
JButton depositButton = new JButton("Do it");
depositButton.addActionListener(new DepositAction());
actionPanel.add(depositButton);
return actionPanel;
|
private javax.swing.JPanel | buildBalancePanel()
JPanel balancePanel = new JPanel(new GridLayout(1, 2));
balancePanel.add(new JLabel("Current Balance:"));
_balanceTextField = new JTextField();
_balanceTextField.setEnabled(false);
balancePanel.add(_balanceTextField);
return balancePanel;
|
protected void | buildGUI()
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.add(buildActionPanel(), BorderLayout.CENTER);
contentPane.add(buildBalancePanel(), BorderLayout.SOUTH);
setContentPane(contentPane);
setSize(250, 100);
|
private void | getAccount()
try {
LockingFactory factory = (LockingFactory) Naming.lookup(ACCOUNT_FACTORY_NAME);
_account = (Account) factory.getServer(_accountNameField.getText());
} catch (Exception e) {
System.out.println("Couldn't find account. Error was \n " + e);
e.printStackTrace();
}
return;
|
private Money | readTextField(javax.swing.JTextField moneyField)
try {
Float floatValue = new Float(moneyField.getText());
float actualValue = floatValue.floatValue();
int cents = (int) (actualValue * 100);
return new PositiveMoney(cents);
} catch (Exception e) {
System.out.println("Field doesn't contain a float");
}
return null;
|
private void | releaseAccount()
_account = null;
return;
|
private void | resetBalanceField()
try {
Money balance = _account.getBalance();
_balanceTextField.setText("Balance: " + balance.toString());
} catch (Exception e) {
System.out.println("Error occurred while getting account balance\n" + e);
}
|