Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help debugging a class! (A lot of Text)

0 views
Skip to first unread message

Michael Doughty

unread,
Nov 16, 2002, 7:06:03 PM11/16/02
to
Hello,
I have an application that handles a set of bank account objects and
I am having a problem debugging the sections that handle the transfer of
money from one account to another. Specifically the sections in the
actionPerformed method dealing with the transferDialog transferButton and
the toAccountBox.
On a side issue, I created the Dialog internally within the
AccountViewer class. I have a method called center in the main class that
centers the Frame on the users screen. Is there a way to use the center
method on the generated internal Dialog?

Here is the dump from the error log JBuilder ouput during program run.

C:\jdk1.3.1_06\bin\javaw -classpath
"A:\Javalab5\classes;C:\jdk1.3.1_06\demo\jfc\Java2D\Java2Demo.jar;C:\jdk1.3.
1_06\jre\lib\i18n.jar;C:\jdk1.3.1_06\jre\lib\jaws.jar;C:\jdk1.3.1_06\jre\lib
\rt.jar;C:\jdk1.3.1_06\jre\lib\sunrsasign.jar;C:\jdk1.3.1_06\lib\dt.jar;C:\j
dk1.3.1_06\lib\htmlconverter.jar;C:\jdk1.3.1_06\lib\tools.jar"
AccountViewer
Exception occurred during event dispatching:
java.lang.NumberFormatException:
javax.swing.JTextField[,164,86,164x43,layout=javax.swing.plaf.basic.BasicTex
tUI$UpdateHandler,alignmentX=null,alignmentY=null,border=javax.swing.plaf.Bo
rderUIResource$CompoundBorderUIResource@5aed57,flags=1184,maximumSize=,minim
umSize=,preferredSize=,caretColor=javax.swing.plaf.ColorUIResource[r=0,g=0,b
=0],disabledTextColor=javax.swing.plaf.ColorUIResource[r=153,g=153,b=153],ed
itable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,r
ight=0],selectedTextColor=javax.swing.plaf.ColorUIResource[r=0,g=0,b=0],sele
ctionColor=javax.swing.plaf.ColorUIResource[r=204,g=204,b=255],columns=0,col
umnWidth=0,command=,horizontalAlignment=LEADING] at
java.lang.Integer.parseInt(Integer.java:409) at
java.lang.Integer.parseInt(Integer.java:458)
at AccountViewer.actionPerformed(AccountViewer.java:477)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1445)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButto
n.java:1499) at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:3
73)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:245)
at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener
.java:211)
at java.awt.Component.processMouseEvent(Component.java:3710)
at java.awt.Component.processEvent(Component.java:3539)
at java.awt.Container.processEvent(Container.java:1159)
at java.awt.Component.dispatchEventImpl(Component.java:2588)
at java.awt.Container.dispatchEventImpl(Container.java:1208)
at java.awt.Component.dispatchEvent(Component.java:2492)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1195)
at java.awt.Window.dispatchEventImpl(Window.java:923)
at java.awt.Component.dispatchEvent(Component.java:2492)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja
va:126) at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java
:93)
at java.awt.Dialog.show(Dialog.java:375)
at AccountViewer.actionPerformed(AccountViewer.java:435)
at javax.swing.JComboBox.fireActionEvent(JComboBox.java:865)
at javax.swing.JComboBox.selectedItemChanged(JComboBox.java:889)
at javax.swing.JComboBox.contentsChanged(JComboBox.java:945)
at
javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel.java:74)
at
javax.swing.DefaultComboBoxModel.setSelectedItem(DefaultComboBoxModel.java:8
1)
at javax.swing.JComboBox.setSelectedItem(JComboBox.java:410)
at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:450)
at
javax.swing.plaf.basic.BasicComboPopup$ListMouseHandler.mouseReleased(BasicC
omboPopup.java:577)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:226)
at java.awt.Component.processMouseEvent(Component.java:3710)
at java.awt.Component.processEvent(Component.java:3539)
at java.awt.Container.processEvent(Container.java:1159)
at java.awt.Component.dispatchEventImpl(Component.java:2588)
at java.awt.Container.dispatchEventImpl(Container.java:1208)
at java.awt.Component.dispatchEvent(Component.java:2492)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1195)
at java.awt.Window.dispatchEventImpl(Window.java:923)
at java.awt.Component.dispatchEvent(Component.java:2492)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja
va:126) at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java
:93)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:80)


This is the class file that has the bugs to root out. I hope the indentation
stays in place.
/**
* <p>Title: Javalab5</p>
* <p>Description: Money management</p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: Doughty's Desktop</p>
* @author Michael Doughty
* @version 1.0
*/
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import BankAccount;
import ActivityViewer;
import java.text.DecimalFormat;

public class AccountViewer extends JFrame implements ActionListener
{
private ActivityViewer activityViewer = new ActivityViewer();
private Dialog transferDialog = new Dialog(this,"Transfer Funds",true);
private ObjectInputStream input;
private ObjectOutputStream output;
private Authorization authorization;
private BorderLayout borderLayout1 = new BorderLayout();
private JLabel jLabel1 = new JLabel();
private JPanel jPanel1 = new JPanel();
private JPanel jPanel2 = new JPanel();
private GridLayout gridLayout1 = new GridLayout();
private JLabel jLabel2 = new JLabel();
private JLabel jLabel5 = new JLabel();
private JLabel jLabel6 = new JLabel();
private JTextField chkBalanceTextField = new JTextField();
private JLabel jLabel7 = new JLabel();
private JTextField savBalanceTextField = new JTextField();
private JLabel jLabel8 = new JLabel();
private JTextField hiBalanceTextField = new JTextField();
private JLabel jLabel9 = new JLabel();
private JTextField stBalanceTextField = new JTextField();
private JPanel jPanel3 = new JPanel();
private JButton jButton2 = new JButton();
public BankAccount checking, savings, homeLoan, studentLoan;
private JLabel jLabel3 = new JLabel();
private JComboBox jComboBox1 = new JComboBox();
private JComboBox jComboBox2 = new JComboBox();
private JComboBox jComboBox3 = new JComboBox();
private JComboBox jComboBox4 = new JComboBox();
private JButton saveButton = new JButton();
private JButton loadButton = new JButton();
public DecimalFormat twoDigits = new DecimalFormat("0.00");
private JButton createNewRecordsButton = new JButton();
private AccountCreater accountCreater = new AccountCreater();
private BorderLayout borderLayout2 = new BorderLayout();
private JPanel jPanel4 = new JPanel();
private JPanel jPanel5 = new JPanel();
private GridLayout gridLayout2 = new GridLayout();
private JLabel jLabel12 = new JLabel();
private JTextField FromAccountText = new JTextField();
private JTextField FromBalanceText = new JTextField();
private JLabel jLabel13 = new JLabel();
private JComboBox toAccountBox = new JComboBox();
private JTextField toBalanceText = new JTextField();
private JLabel jLabel14 = new JLabel();
private JTextField transferAmountText = new JTextField();
private JButton transferButton = new JButton();
private JButton transferCloseButton = new JButton();


public AccountViewer()
{
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}

public void sendActivity(String accType, String activity)
{
if(accType.equals("Checking"))
checking.setActivity(activity);
if(accType.equals("Savings"))
savings.setActivity(activity);
if(accType.equals("Home Improvement Loan"))
homeLoan.setActivity(activity);
if(accType.equals("Student Loan"))
studentLoan.setActivity(activity);
}

public void inFile()
{
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = fileChooser.showOpenDialog(this);
if(result == JFileChooser.CANCEL_OPTION)
return;

File fileName = fileChooser.getSelectedFile();

if(fileName == null || fileName.getName().equals(""))
JOptionPane.showMessageDialog(this,"Invalid File Name","Invalid File
Name",JOptionPane.ERROR_MESSAGE);
else
{
try
{
input = new ObjectInputStream(new FileInputStream(fileName));
loadButton.setEnabled(false);
saveButton.setEnabled(true);
}
catch(IOException ioException)
{
JOptionPane.showMessageDialog(this,"Error Opening
File","Error",JOptionPane.ERROR_MESSAGE);
}
}
}

public void outFile()
{
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = fileChooser.showSaveDialog(this);
if(result == JFileChooser.CANCEL_OPTION)
return;

File fileName = fileChooser.getSelectedFile();

if(fileName == null || fileName.getName().equals(""))
JOptionPane.showMessageDialog(this,"Invalid File Name","Invalid File
Name",JOptionPane.ERROR_MESSAGE);
else
{
try
{
output = new ObjectOutputStream(new FileOutputStream(fileName));
loadButton.setEnabled(true);
saveButton.setEnabled(false);
}
catch(IOException ioException)
{
JOptionPane.showMessageDialog(this,"Error Opening
File","Error",JOptionPane.ERROR_MESSAGE);
}
}
}

public void inFileClose()
{
try{input.close();}
catch(IOException ioException)
{JOptionPane.showMessageDialog(this,"Error Closing
File","Error",JOptionPane.ERROR_MESSAGE);
System.exit(1);}
}

public void outFileClose()
{
try{output.close();}
catch(IOException ioException)
{JOptionPane.showMessageDialog(this,"Error Closing
File","Error",JOptionPane.ERROR_MESSAGE);
System.exit(1);}
}

public void openNewAccounts()
{
checking = new BankAccount(1,"Checking","320 Ridgeway",30000);
savings = new BankAccount(2,"Savings","320 Ridgeway",4000000);
homeLoan = new BankAccount(3,"Home Improvement Loan","320
Ridgeway",10000);
studentLoan = new BankAccount(4,"Student Loan","320 Ridgeway",300);
loadDialog();
}

protected final void center()
{
Toolkit t = Toolkit.getDefaultToolkit();
Dimension d = t.getScreenSize();
Dimension e = this.getSize();
this.setLocation( ( (int) d.getWidth() - (int) e.getWidth() )/2,
( (int) d.getHeight() - (int) e.getHeight() )/2 );
}

public void readRecords()
{
if(output != null)
outFileClose();

inFile();

try
{
checking = (BankAccount) input.readObject();
savings = (BankAccount) input.readObject();
homeLoan = (BankAccount) input.readObject();
studentLoan = (BankAccount) input.readObject();
loadDialog();
}
catch(EOFException endOfFileException)
{
loadButton.setEnabled(false);
}
catch(ClassNotFoundException classNotFoundException)
{
JOptionPane.showMessageDialog(this,"Unable to create object","Class
Not Found",JOptionPane.ERROR_MESSAGE);
}
catch(IOException ioException)
{
JOptionPane.showMessageDialog(this,"Error during read from file","Read
Error",JOptionPane.ERROR_MESSAGE);
}


}

public void writeRecords()
{
if(input != null)
inFileClose();

outFile();
try
{
output.writeObject(checking);
output.writeObject(savings);
output.writeObject(homeLoan);
output.writeObject(studentLoan);
}
catch(NumberFormatException formatException)
{
JOptionPane.showMessageDialog(this,"Bad Account number or
balance","Invalid Number Format",JOptionPane.ERROR_MESSAGE);
}
catch(IOException ioException)
{
outFileClose();
}
}

private void loadDialog()
{
chkBalanceTextField.setText (Integer.toString(checking.getBalance()));
savBalanceTextField.setText(Integer.toString(savings.getBalance()));
hiBalanceTextField.setText(Integer.toString(homeLoan.getBalance()));
stBalanceTextField.setText(Integer.toString(studentLoan.getBalance()));
}

public static void main(String[] args)
{
AccountViewer accountViewer = new AccountViewer();
accountViewer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

private void jbInit() throws Exception
{
transferDialog.setSize(500,200);
JPanel transferFrame = new JPanel();
transferFrame.setLayout(borderLayout2);
jPanel4.setLayout(gridLayout2);
gridLayout2.setColumns(3);
gridLayout2.setRows(3);
jLabel12.setText("From");
jLabel13.setText("To");
jLabel14.setText("Transfer Amount");
transferButton.setText("Transfer");
transferCloseButton.setActionCommand("CloseTransfer");
transferCloseButton.setText("Close");
transferDialog.add(transferFrame);
jLabel1.setFont(new java.awt.Font("Dialog", 1, 18));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("Account Viewer");
this.getContentPane().setLayout(borderLayout1);
jPanel2.setLayout(gridLayout1);
gridLayout1.setColumns(3);
gridLayout1.setHgap(2);
gridLayout1.setRows(5);
gridLayout1.setVgap(2);
jLabel2.setText("Account");
jLabel5.setText("Balance");
jLabel6.setText("Checking");
jLabel7.setText("Savings");
jLabel8.setText("Home Improvement Loan");
jLabel9.setText("Student Loan");
jButton2.setText("Close");
jButton2.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
System.exit(0);
}
}
);
jLabel3.setText("Menu Options");
saveButton.setText("Save");
saveButton.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
writeRecords();
}
}
);
loadButton.setText("Load");
loadButton.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
readRecords();
}
}
);

createNewRecordsButton.setText("Create");
createNewRecordsButton.addActionListener(this);
this.setTitle("Money Manager by Michael Doughty");
jPanel1.add(jLabel1);
this.getContentPane().add(jPanel2, BorderLayout.CENTER);
jPanel2.add(jLabel2, null);
jPanel2.add(jLabel5, null);
jPanel2.add(jLabel3, null);
jPanel2.add(jLabel6, null);
jPanel2.add(chkBalanceTextField, null);
jPanel2.add(jComboBox1, null);
jPanel2.add(jLabel7, null);
jPanel2.add(savBalanceTextField, null);
jPanel2.add(jComboBox2, null);
jPanel2.add(jLabel8, null);
jPanel2.add(hiBalanceTextField, null);
jPanel2.add(jComboBox3, null);
jPanel2.add(jLabel9, null);
jPanel2.add(stBalanceTextField, null);
jPanel2.add(jComboBox4, null);
this.getContentPane().add(jPanel1, BorderLayout.NORTH);
this.getContentPane().add(jPanel3, BorderLayout.SOUTH);
jPanel3.add(createNewRecordsButton, null);
jPanel3.add(loadButton, null);
jPanel3.add(saveButton, null);
jPanel3.add(jButton2, null);
transferFrame.add(jPanel4, BorderLayout.CENTER);
jPanel4.add(jLabel12, null);
jPanel4.add(FromAccountText, null);
jPanel4.add(FromBalanceText, null);
jPanel4.add(jLabel13, null);
jPanel4.add(toAccountBox, null);
jPanel4.add(toBalanceText, null);
jPanel4.add(jLabel14, null);
jPanel4.add(transferAmountText, null);
transferFrame.add(jPanel5, BorderLayout.SOUTH);
jPanel5.add(transferButton, null);
jPanel5.add(transferCloseButton, null);
jComboBox1.addItem("Select Option");
jComboBox1.addItem("View Activity");
jComboBox1.addItem("Transfer Funds");
jComboBox1.addItem("Change Address");
jComboBox1.addActionListener(this);
jComboBox2.addItem("Select Option");
jComboBox2.addItem("View Activity");
jComboBox2.addItem("Transfer Funds");
jComboBox2.addItem("Change Address");
jComboBox2.addActionListener(this);
jComboBox3.addItem("Select Option");
jComboBox3.addItem("View Activity");
jComboBox3.addItem("Change Address");
jComboBox3.addActionListener(this);
jComboBox4.addItem("Select Option");
jComboBox4.addItem("View Activity");
jComboBox4.addItem("Change Address");
jComboBox4.addActionListener(this);
toAccountBox.addItem("Select Account");
toAccountBox.addItem("Checking");
toAccountBox.addItem("Savings");
toAccountBox.addItem("Home Improvement Loan");
toAccountBox.addItem("Student Loan");
toAccountBox.addActionListener(this);
transferButton.addActionListener(this);
transferCloseButton.addActionListener(this);


setSize(500,250);
center();
show();
authorization = new Authorization();
authorization.setModal(true);
authorization.setResizable(false);
authorization.setTitle("Login");
authorization.show();
}

public void actionPerformed(ActionEvent event)
{
if(event.getActionCommand() == "Create")
{
accountCreater = new AccountCreater();
accountCreater.setModal(true);
accountCreater.setResizable(true);
accountCreater.setTitle("Recordset Creation Screen by Michael
Doughty");
accountCreater.show();

checking.setBalance(accountCreater.chk.getBalance());
checking.setActivity(accountCreater.chk.getActivity());
savings.setBalance(accountCreater.sav.getBalance());
savings.setActivity(accountCreater.sav.getActivity());
homeLoan.setBalance(accountCreater.hil.getBalance());
homeLoan.setActivity(accountCreater.hil.getActivity());
studentLoan.setBalance(accountCreater.stu.getBalance());
studentLoan.setActivity(accountCreater.stu.getActivity());
loadDialog();
}

// Determine which options are selected from ComboBoxes
if(jComboBox1.getSelectedItem().equals("View Activity"))
{
activityViewer.viewAccount(checking);
activityViewer.show();
}
if(jComboBox2.getSelectedItem().equals("View Activity"))
{
activityViewer.viewAccount(savings);
activityViewer.show();
}
if(jComboBox3.getSelectedItem().equals("View Activity"))
{
activityViewer.viewAccount(homeLoan);
activityViewer.show();
}
if(jComboBox4.getSelectedItem().equals("View Activity"))
{
activityViewer.viewAccount(studentLoan);
activityViewer.show();
}

if(jComboBox1.getSelectedItem().equals("Transfer Funds"))
{
FromAccountText.setText(checking.getAccountType());
FromBalanceText.setText(Integer.toString(checking.getBalance()));
transferDialog.show();
}
if(jComboBox2.getSelectedItem().equals("Transfer Funds"))
{
FromAccountText.setText(savings.getAccountType());
FromBalanceText.setText(Integer.toString(savings.getBalance()));
transferDialog.show();
}

if(event.getSource() == toAccountBox)
{
if(FromAccountText.equals("Checking") &&
toAccountBox.getSelectedItem().equals("Checking"))
{
sameAccount();
}
else if(toAccountBox.getSelectedItem().equals("Checking"))
{
toBalanceText.setText(Integer.toString(checking.getBalance()));
}

if(FromAccountText.equals("savings") &&
toAccountBox.getSelectedItem().equals("savings"))
{
sameAccount();
}
if(toAccountBox.getSelectedItem().equals("Savings"))
{
toBalanceText.setText(Integer.toString(savings.getBalance()));
}

if(toAccountBox.getSelectedItem().equals("Home Improvement Loan"))
{
toBalanceText.setText(Integer.toString(homeLoan.getBalance()));
}

if(toAccountBox.getSelectedItem().equals("Student Loan"))
{
toBalanceText.setText(Integer.toString(studentLoan.getBalance()));
}
}

if(event.getSource() == transferButton)
{
int myInt = Integer.parseInt(transferAmountText.toString());

if(FromAccountText.equals("Checking"))
{
checking.withdrawal(myInt);
}

if(FromAccountText.equals("Savings"))
{
savings.withdrawal(myInt);
}

if(toAccountBox.getSelectedItem().equals("Checking"))
{
checking.deposit(myInt);
}

if(toAccountBox.getSelectedItem().equals("Savings"))
{
savings.deposit(myInt);
}

if(toAccountBox.getSelectedItem().equals("Home Improvement Loan"))
{
homeLoan.deposit(myInt);
}

if(toAccountBox.getSelectedItem().equals("Student Loan"))
{
studentLoan.deposit(myInt);
}
}

if(event.getSource() == transferCloseButton)
{
transferDialog.hide();
loadDialog();
}

// Do Change of Address
if(jComboBox1.getSelectedItem().equals("Change Address"))
{
checking.setAddress(JOptionPane.showInputDialog(this,"Enter New
Address","Change Address",JOptionPane.QUESTION_MESSAGE));
}

if(jComboBox2.getSelectedItem().equals("Change Address"))
{
savings.setAddress(JOptionPane.showInputDialog(this,"Enter New
Address","Change Address",JOptionPane.QUESTION_MESSAGE));
}

if(jComboBox3.getSelectedItem().equals("Change Address"))
{
homeLoan.setAddress(JOptionPane.showInputDialog(this,"Enter New
Address","Change Address",JOptionPane.QUESTION_MESSAGE));
}

if(jComboBox4.getSelectedItem().equals("Change Address"))
{
studentLoan.setAddress(JOptionPane.showInputDialog(this,"Enter New
Address","Change Address",JOptionPane.QUESTION_MESSAGE));
}
}

public void sameAccount()
{
JOptionPane.showMessageDialog(this,"You cannot transfer into the same
account","Selection Error",JOptionPane.ERROR_MESSAGE);
}
}

Thanks for taking the time to look over my code, and offering your opinions
on how to fix it.

--
Michael Doughty
mdou...@ameritech.net
medo...@iupui.edu

Andrew Hobbs

unread,
Nov 16, 2002, 7:55:55 PM11/16/02
to

"Michael Doughty" <mdou...@ameritech.net> wrote in message
news:L3BB9.947$4j5.5...@newssvr28.news.prodigy.com...
> Hello,

>
> C:\jdk1.3.1_06\bin\javaw -classpath
>
"A:\Javalab5\classes;C:\jdk1.3.1_06\demo\jfc\Java2D\Java2Demo.jar;C:\jdk1.3.
>
1_06\jre\lib\i18n.jar;C:\jdk1.3.1_06\jre\lib\jaws.jar;C:\jdk1.3.1_06\jre\lib
>
\rt.jar;C:\jdk1.3.1_06\jre\lib\sunrsasign.jar;C:\jdk1.3.1_06\lib\dt.jar;C:\j
> dk1.3.1_06\lib\htmlconverter.jar;C:\jdk1.3.1_06\lib\tools.jar"
> AccountViewer
> Exception occurred during event dispatching:
> java.lang.NumberFormatException:
>
javax.swing.JTextField[,164,86,164x43,layout=javax.swing.plaf.basic.BasicTex
>
tUI$UpdateHandler,alignmentX=null,alignmentY=null,border=javax.swing.plaf.Bo
>
rderUIResource$CompoundBorderUIResource@5aed57,flags=1184,maximumSize=,minim
>
umSize=,preferredSize=,caretColor=javax.swing.plaf.ColorUIResource[r=0,g=0,b
>
=0],disabledTextColor=javax.swing.plaf.ColorUIResource[r=153,g=153,b=153],ed
>
itable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,r
>
ight=0],selectedTextColor=javax.swing.plaf.ColorUIResource[r=0,g=0,b=0],sele
>
ctionColor=javax.swing.plaf.ColorUIResource[r=204,g=204,b=255],columns=0,col
> umnWidth=0,command=,horizontalAlignment=LEADING] at

Hi,

As your exception states, it cannot format the (JTextField)
transferAmountText.toString() output as an integer (The result of the
toString method is given, so it is not surprising). I would suggest you
change it to (JTextField) transferAmountText.getText();

I would also suggest that your class should be split into two. The actual
user interface and a bank class which does all the interaction with the
accounts etc. You interface then just sends and gets info from the bank
class. It would make the code much easier to follow and provide less
coupling between the interface and the banking side of things. You could
then simplify a lot of the code by making components serve multiple
functions depending upon what is required at that moment. That way you
could get rid of a lot of the if statements.

Andrew

0 new messages