This program is to design a gui for users to add any loan amount, term, and APR; the program then gives a monthly note amount in that field. I cannot figure out what I'm doing wrong. I also cannot get the reset button to work. Can anyone give me an idea of what I've done wrong?
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.text.DecimalFormat;
class BeemanWk2 extends JFrame {
DecimalFormat Dollar = new DecimalFormat ("$###,###.00");
//Set up row 1
private JLabel principalLabel = new JLabel("Loan Amount: ");
private JTextField principalText = new JTextField(10);
//Set up row 2
private JLabel termLabel = new JLabel("Term: ");
private JTextField termText = new JTextField(10);
//Set up row 3
private JLabel rateLabel = new JLabel("APR: ");
private JTextField rateText = new JTextField(10);
//Set up row 4
private JLabel payAmtLabel = new JLabel ("Monthly Note: ");
private JTextField payAmtText = new JTextField (10);
public BeemanWk2() {
JButton btnCalculate = new JButton("Calculate");
JButton btnReset = new JButton("Reset");
JPanel content = new JPanel();
content.setLayout(new BoxLayout(content,BoxLayout.Y_AXIS));
content.add(principalLabel);
content.add(principalText);
content.add(termLabel);
content.add(termText);
content.add(rateLabel);
content.add(rateText);
content.add(payAmtLabel);
content.add(payAmtText);
content.add(btnCalculate);
content.add(btnReset);
setContentPane(content);
setTitle("Mortgage Payment Calculator");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
}
class btnCalculateListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
double principal = Double.parseDouble(principalText.getText());
double term = Double.parseDouble(termText.getText());
double rate = Double.parseDouble(rateText.getText());
onButtonCalculate();
}
private void onButtonCalculate() {
}
}
public static double calculatePayment(double principal, double rate, int term){
double monthlyInt = rate / 12;
double monthlyPayment = (principal * monthlyInt)
/ (1 - Math.pow(1/ (1 + monthlyInt), term* 12)); //*Shows 1 monthly payment multiplied by 12 to make one complete year.
return (monthlyPayment);
class btnResetListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
}
//Main Method
public static void main(String[]args)
{
BeemanWk2 window = new BeemanWk2();
window.setVisible(true);
}
}