import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.text.*; import java.io.*;
// Sets the Mortgage1 class which allows a user to calculate a mortgage loan
public class Mortgage1 extends JFrame { // Creates the buttons that will be used private JButton calcButton = new JButton("Calculate"); private JButton resetButton = new JButton("Reset"); // Creates the labels for the fields to be used private final JLabel amountLabel = new JLabel("Loan Amount:"); private final JLabel termLabel = new JLabel("Term (in years):"); private final JLabel rateLabel = new JLabel("Rate (actual %):"); private final JLabel mpayLabel = new JLabel("Monthly Payment:"); // Creates the text fields for the user input private JTextField amountField; private JTextField termField; private JTextField rateField; private JTextField mpayField; // Adds the title to the window and defines window diminsions public Mortgage1() { super("PRG/421 Mortgage Calculator"); initComponents(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(275, 175); setVisible(true); setResizable(false); setLocationRelativeTo(null); MenuBar mnuBar = new MenuBar(); setMenuBar(mnuBar); Menu mnuFile = new Menu("File", true); mnuBar.add(mnuFile); MenuItem mnuFileExit = new MenuItem("Exit"); mnuFile.add(mnuFileExit); Menu mnuHelp = new Menu("Help", true); mnuBar.add(mnuHelp); MenuItem mnuAbout = new MenuItem("About"); mnuHelp.add(mnuAbout); mnuFileExit.addActionListener(new ExitMenuHandler()); //mnuFileExit.setActionCommand("Exit");
}
// Creates the actual buttons and fields in a usable way public void initComponents() {