public class GUI extends javax.swing.JFrame {
MortgageCalculator calculate = new MortgageCalculator();
//Creates new form MortgageCalculatorGUI
public GUI() {
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">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
JLabelPrincipal = new javax.swing.JLabel();
JLabelInterestRate = new javax.swing.JLabel();
JLabelTerm = new javax.swing.JLabel();
jTextFieldPrincipal = new javax.swing.JTextField();
jTextFieldInterestRate = new javax.swing.JTextField();
jTextFieldTerm = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
jButtonSubmit = new javax.swing.JButton();
jButtonClear = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextAreaMonthlyPayment = new javax.swing.JTextArea();
jLabelMonthlyPaymentInfo = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextAreaAmortizationInfo = new javax.swing.JTextArea();
jLabelAmortizationInfo = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
JLabelPrincipal.setText("Principal");
JLabelInterestRate.setText("Interest Rate");
JLabelTerm.setText("Term");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(JLabelTerm, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(JLabelInterestRate, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(JLabelPrincipal, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextFieldTerm, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)
.addComponent(jTextFieldInterestRate, javax.swing.GroupLayout.Alignment.LEADING))
.addComponent(jTextFieldPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(JLabelPrincipal)
.addComponent(jTextFieldPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(JLabelInterestRate)
.addComponent(jTextFieldInterestRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(JLabelTerm)
.addComponent(jTextFieldTerm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jButtonSubmit.setText("Submit");
jButtonSubmit.setDoubleBuffered(true);
jButtonSubmit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonSubmitActionPerformed(evt);
}
});
jButtonClear.setText("Clear");
jButtonClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonClearActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButtonSubmit, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButtonClear)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonClear, jButtonSubmit});
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonSubmit)
.addComponent(jButtonClear))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jTextAreaMonthlyPayment.setColumns(20);
jTextAreaMonthlyPayment.setRows(5);
jScrollPane1.setViewportView(jTextAreaMonthlyPayment);
jLabelMonthlyPaymentInfo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabelMonthlyPaymentInfo.setText("Monthly Payment Information");
jTextAreaAmortizationInfo.setColumns(20);
jTextAreaAmortizationInfo.setEditable(false);
jTextAreaAmortizationInfo.setRows(5);
jScrollPane2.setViewportView(jTextAreaAmortizationInfo);
jLabelAmortizationInfo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabelAmortizationInfo.setText("Loan Amortization Information");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jScrollPane2)
.addComponent(jLabelMonthlyPaymentInfo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
.addComponent(jScrollPane1)
.addComponent(jLabelAmortizationInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabelMonthlyPaymentInfo)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabelAmortizationInfo)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
// Action listener for Submit button
private void jButtonSubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSubmitActionPerformed
calculate.displayLoanInformation(jTextAreaMonthlyPayment);
calculate.amortization(jTextAreaAmortizationInfo);
}//GEN-LAST:event_jButtonSubmitActionPerformed
// Action listener for Clear button
private void jButtonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonClearActionPerformed
jTextFieldPrincipal.setText("");
jTextFieldTerm.setText("");
jTextFieldInterestRate.setText("");
jTextAreaMonthlyPayment.setText("");
jTextAreaAmortizationInfo.setText("");
}//GEN-LAST:event_jButtonClearActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
//Create and display the form
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new GUI().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel JLabelInterestRate;
private javax.swing.JLabel JLabelPrincipal;
private javax.swing.JLabel JLabelTerm;
private javax.swing.JButton jButtonClear;
private javax.swing.JButton jButtonSubmit;
private javax.swing.JLabel jLabelAmortizationInfo;
private javax.swing.JLabel jLabelMonthlyPaymentInfo;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextArea jTextAreaAmortizationInfo;
private javax.swing.JTextArea jTextAreaMonthlyPayment;
private javax.swing.JTextField jTextFieldInterestRate;
private javax.swing.JTextField jTextFieldPrincipal;
private javax.swing.JTextField jTextFieldTerm;
// End of variables declaration//GEN-END:variables
}