My problem is that I create a panel asking the balance first. Panel works good but when I click on make a transaction and input transcode and amount I get an error on the following lines.
There is a problem and gives errors like abstract button, defaultbutton, JToggle and others.
I don't know if it has to do with the order of how it organized it worked yesterday but Listing the transactions was giving me problems after a few changes and saves computer crashed and know I can't remember what I changed so the addTrans could work again.
Any help would be appreciate it. I will be working on the program and I will update it here if I find something new.
import java.awt.Font; import java.text.DecimalFormat; import javax.swing.JOptionPane; import java.util.ArrayList; import javax.swing.JTextArea; public class CheckingAccount { private double balance; private double sCharge; private ArrayList<Transaction> transList; private static int transCount; public CheckingAccount(double initialBalance) { balance = initialBalance; sCharge = 0.0; transCount = 0; } public double getBalance() { return balance; } public void setBalance(double TransAmt, int TransCode) { if(TransCode == 1) balance = balance - TransAmt; else //if(tCode == 2) balance = balance + TransAmt; } public double getServiceCharge() { return sCharge; } public void setServiceCharge(double currentServiceCharge) { sCharge =+ currentServiceCharge; } public void addTrans(Transaction newTrans) { [B]transList.add(newTrans);[/B]//On This line //transCount++; } public static int getTransCount() //returns the current value of transCount; { return transCount; } public Transaction getTrans(int i) // returns the i-th Transaction object in the list { return transList.get(i); } }
This next code is only part of the Panel and only the first if there are 4 if else if statements
private class RadioButtonListener implements ActionListener { Transaction transaction; CheckingAccount account; public void actionPerformed (ActionEvent event) { if(event.getSource() == trans) { double checkC = .15, depositC = .10, sCharge = 0.0; String message =""; int TransCode; double TransAmt,pCheck, pDeposit, balance,finalB; int count = 0, transCount = 0; account = new CheckingAccount(Main.balance); DecimalFormat formatter = new DecimalFormat("#0.00"); //CheckingAccount account = new CheckingAccount (Main.balance); account.setServiceCharge(sCharge); TransCode = Main.getTransCode(); if(TransCode == 1) { TransAmt = Main.getTransAmt(); transaction = new Transaction(transCount,TransCode,TransAmt); [B]account.addTrans(transaction);[/B[B]]//and on this line[/B] pCheck = Main.processCheck(Main.balance, TransAmt); transaction = new Transaction(account.getTransCount(), 3, pCheck); account.addTrans(transaction); balance = pCheck; message = "Transaction:Check in amount of $"+ formatter.format(TransAmt) + "\n" + "Current Balance : $"+formatter.format(balance) +"\n" +"Service Charge: Check---charge $0.15\n"; if(balance < 500.0){ if(count == 0) { sCharge += 5.00; account.setServiceCharge(sCharge); transaction = new Transaction(transCount,3, 5.00); account.addTrans(transaction); message += "Service Charge : Below $500 --- $5.00\n"; } count++; } if (balance <0){ sCharge += 10.00; account.setServiceCharge(sCharge); transaction = new Transaction(transCount,3, 10.00); account.addTrans(transaction); message += "Service Charge : Below $0 --- $10.00\n"; } if (balance <= 50.0){ message += "Warning: Balance below $50\n"; } sCharge += checkC; account.setServiceCharge(sCharge); message += "Tota Service Charge:$"+formatter.format(sCharge); JOptionPane.showMessageDialog(null, message); }//first if