University of Phoenix
David Silberberg
POS 407
04-19-2005
Program
/* * MortgageGui.java * Version 4 * Created on April 19, 2005 * Use a graphical interface to allow a user to input a principle amount, interest rate * and term of loan then calculate loan payment. * Added text field to show amortization of loan. Also checked for last payment equal to * less than monthly payment. Added in the ability to select a predefined interest rate * and term. Added in the ability to read in from a file (file is found in C:\mortgagein.txt). * * * @author ************ */ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.text.NumberFormat; import java.text.DecimalFormat; …show more content…
row4.add(mthPay); mthPay.setEditable(false); pane.add(row4); FlowLayout layout5 = new FlowLayout(FlowLayout.CENTER, 2, 2); row5.setLayout(layout5); row5.add(Calculate); row5.add(Reset); row5.add(Quit); pane.add(row5); FlowLayout layout6 = new FlowLayout(FlowLayout.CENTER, 2, 2); row6.setLayout(layout6); row6.add(header); row6.add(scroll); mortg.setEditable(false); pane.add(row6);
setVisible(true);
}
public void actionPerformed (ActionEvent evt){ Object source = evt.getSource(); choice = combo.getSelectedIndex(); if (source == Calculate){ //calculates mortgage when Calculate button is clicked switch (choice) { case 0: calculate(); break; case 1: years.setText("7"); irate.setText("5.35"); calculate(); break; case 2: years.setText("15"); irate.setText("5.50"); calculate(); break; case 3: years.setText("30"); irate.setText("5.75"); calculate(); …show more content…
case 4: readText(); calculate(); break; }
} else if (source == Reset){ //Resets values to a default value when pressed princ.setText("100000"); mthPay.setText(""); mortg.setText(""); years.setText(""); irate.setText(""); textFile.setText(""); total = 0;
} else if (source == Quit){ //exits program when quit button is pressed