Hi I am hoping to get some help here because I am completely lost. I am using netbeans and have to come up with this: Write the program in Java (with a graphical user interface) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage. I have ben reading to try and figure this out. I get results in my run window like normal but I dont get any results in the GUI.
package ChngReq4Pkg;
import java.text.DecimalFormat;
/**
*
* @author
*/
public class ChangeRequest4 extends javax.swing.JFrame {
/**
* Creates new form ChangeRequest4
*/
public ChangeRequest4() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
calculate = new javax.swing.JButton();
loanCalculation = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jTextField1 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
setTitle("Loan Calculator");
calculate.setText("Calculate");
calculate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
calculateActionPerformed(evt);
}
});
loanCalculation.setText("Loan");
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1))
.addGroup(layout.createSequentialGroup()
.addGap(185, 185, 185)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.TRAILING)
.addComponent(calculate)
.addGroup(layout.createSequentialGroup()
.addComponent(loanCalculation)
.addGap(18, 18, 18)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 212, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(loanCalculation)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(19, 19, 19)
.addComponent(calculate, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
.addGap(51, 51, 51))
);
pack();
}// </editor-fold>
private void calculateActionPerformed(java.awt.event.ActionEven t evt) {
}
private void jTextField1ActionPerformed(java.awt.event.ActionEv ent evt) {
// TODO add your handling code here:
}
public static void main(String args[]) {
double annualInterest = 5.75; //This is the annual interest rate
double loanAmount = 200000; //This is the loan amount
double loanLengthInYears = 30; //This is the length of the loan in years
//Formuals bieng used are:
double monthlyInterest = annualInterest / 100 / 12;
double loanLengthInMonths = loanLengthInYears * 12;
double monthlyPayment = (loanAmount * monthlyInterest) * (1 + Math.pow((1 - monthlyInterest), loanLengthInYears));
DecimalFormat decimalPlaces=new DecimalFormat("0.00");//Rounds up the dollar amount
System.out.println("MortgageCalculator");
System.out.println("Annual Interest: 5.75%");
System.out.println("Loan Amount: $200,000");
System.out.println("Loan Length: 30 years");
System.out.println("The Monthly Payment is $" + decimalPlaces.format(monthlyPayment));
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the
* default look and feel. For details see
* How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClass Name());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ChangeRequest4. class.getName()).log(java.util.logging.Level.SEVER E, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ChangeRequest4. class.getName()).log(java.util.logging.Level.SEVER E, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ChangeRequest4. class.getName()).log(java.util.logging.Level.SEVER E, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ChangeRequest4. class.getName()).log(java.util.logging.Level.SEVER E, null, ex);
}
//</editor-fold>
/*
* Create and display the form
*/
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ChangeRequest4().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton calculate;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JLabel loanCalculation;
// End of variables declaration
}