I need a little help with this code, I cannot get it right, and i know it is something simple that i am missing. Can someone help me out please.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.text.NumberFormat;


public class week2 extends JFrame implements ActionListener
{

//declaring fields for GUI
JTextField mortgageAmountField, interestRateField, yearsTermField, monthlyPayField;JButton monthButton;
JFrame frame;
int buttonCount = 0;
DecimalFormat fmt = new DecimalFormat("0.00");

//assigning labels to the fields
JLabel mortgageAmountLabel = new JLabel("Mortgage Amount:");
JLabel interestRateLabel = new JLabel("Interest Rate:");
JLabel yearsTermLabel=new JLabel("Term (Years):");
JLabel monthlyPayLabel=new JLabel();


public week2()
{
//declaring the title of the program 
frame = new JFrame("Mortgage Calculator");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//declaring panels 1 and 2
JPanel Panel1 = new JPanel();
JPanel Panel2 = new JPanel();

//assigning buttons to the panels
Panel1.add(mortgageAmountLabel);
mortgageAmountField = new JTextField(15);
Panel1.add(mortgageAmountField);

Panel1.add(interestRateLabel);
interestRateField = new JTextField(5);
Panel1.add(interestRateField);

Panel1.add(yearsTermLabel);
yearsTermField = new JTextField(5);
Panel1.add(yearsTermField);

Panel2.add(monthlyPayLabel);
monthlyPayField = new JTextField(5);
Panel2.add(monthlyPayField);

monthButton = new JButton("Reset");
monthButton.addActionListener(this);
Panel2.add(monthButton);

monthButton = new JButton("Exit");
monthButton.addActionListener(this);
Panel2.add(monthButton);

//setting up the quit button for the user to calculate the program
monthButton = new JButton("Calculate");
monthButton.addActionListener(this);
Panel2.add(monthButton);


//indicating the border layout of our frames
frame.getContentPane().add(Panel1, BorderLayout.NORTH);
frame.getContentPane().add(Panel2, BorderLayout.SOUTH);
frame.setSize(700, 100);
frame.setResizable(true);


frame.show();


}

//activating the action event so the user's input is taken
public void actionPerformed(ActionEvent event){
if(event.getSource() == monthButton)


public void mortgageCalc1() {


double ortgageAmount=Double.parseDouble(mortgageAmountField.getText()); //O= Original amount of loan-hard coded
double interestRate=Double.parseDouble(interestRateField.getText()); //I=Interest rate-hard coded
double yearsTerm=Double.parseDouble(yearsTermField.getText()); //T=Term of loan- hard coded
double monthlyPay = (mortgageAmount*(interestRate / 12))/ (1 - (Math.pow(1 / (1 + (interestRate / 12)), yearsTerm))); 



mortgageCalc1 = new mortgageCalc1(this);



//display the monthly payment 
monthlyPayLabel.setText("Your Monthly Payment will be: " + fmt.format(monthlyPay)); 

//continue with button actionlistener 
buttonCount++;
}

}


public static void main(String[] args)
{
week2 cal = new week2();
}

}
//end of programming

You have 2 JFrames!

Can you point that out for me, I do not see it.

Does your IDE have a Search? Try looking for where there is definition of a JFrame.
Does the main class extend JFrame?

I do have the search and I see the instances of JFrame, but I am still not sure which one is causing the issue, can someone explain it and point out what the problem is so i can correct it and not do it again.

1st way: Create a class Week that is derived from another class (here JFrame)
Week is now a subclass of JFrame class
public class Week2 extends JFrame{

2nd way: Create a class Week that is derived by default from Object
public class Week1 {
And in this class create field JFrame frame;

Which strategy you want to select?

some info:
http://java.sun.com/docs/books/tutorial/java/IandI/subclasses.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.