tbarnes2788
Programmer
I created this swing applet to balance my checking account but I can not get it to calculate. Here's the code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//Create a Swing applet that will calculats the current balance of a
//checking account in a JTextField.
public class JCalculateBalance extends JApplet implements ActionListener
{
JLabel beginBal = new JLabel("beginning balance");
JLabel check = new JLabel("check amount");
JLabel deposit = new JLabel("deposit amount");
JButton calcButton = new JButton("Calculate");
JLabel EndBalResult = new JLabel ("Thank You");
JLabel totalResult = new JLabel("Thank You");
Font bigFont = new Font("TimesRoman",Font.ITALIC,24);
public void init()
{
Container con = getContentPane();
con.setLayout(new FlowLayout());
beginBal.setFont(bigFont);
con.add(beginBal);
con.add(check);
con.add(deposit);
con.add(calcButton);
calcButton.addActionListener(this);
con.add(EndBalResult);
con.add(totalResult);
}
public void start()
{
EndBalResult.setText("Your Current Balance Is");
totalResult.setText("Thank You");
repaint();
}
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if (source == calcButton)
{
String response = JOptionPane.showInputDialog(null, "Enter beginning balance");
double[]beginBal = {300};
double[]check = {100, 10, 40};
double[] deposit = {200, 60, 40};
double doublebalance = Double.parseDouble("300.00");
double doublecheck = Double.parseDouble("150.00");
double doubledeposit = Double.parseDouble("300.00");
double x = 0.0, a = 0;
EndBal = beginBal + deposit - check;
EndBalResult.getText("$" + EndBal);
totalResult.setText("currentBalance");
}
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//Create a Swing applet that will calculats the current balance of a
//checking account in a JTextField.
public class JCalculateBalance extends JApplet implements ActionListener
{
JLabel beginBal = new JLabel("beginning balance");
JLabel check = new JLabel("check amount");
JLabel deposit = new JLabel("deposit amount");
JButton calcButton = new JButton("Calculate");
JLabel EndBalResult = new JLabel ("Thank You");
JLabel totalResult = new JLabel("Thank You");
Font bigFont = new Font("TimesRoman",Font.ITALIC,24);
public void init()
{
Container con = getContentPane();
con.setLayout(new FlowLayout());
beginBal.setFont(bigFont);
con.add(beginBal);
con.add(check);
con.add(deposit);
con.add(calcButton);
calcButton.addActionListener(this);
con.add(EndBalResult);
con.add(totalResult);
}
public void start()
{
EndBalResult.setText("Your Current Balance Is");
totalResult.setText("Thank You");
repaint();
}
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if (source == calcButton)
{
String response = JOptionPane.showInputDialog(null, "Enter beginning balance");
double[]beginBal = {300};
double[]check = {100, 10, 40};
double[] deposit = {200, 60, 40};
double doublebalance = Double.parseDouble("300.00");
double doublecheck = Double.parseDouble("150.00");
double doubledeposit = Double.parseDouble("300.00");
double x = 0.0, a = 0;
EndBal = beginBal + deposit - check;
EndBalResult.getText("$" + EndBal);
totalResult.setText("currentBalance");
}
}
}