Help with GUIs in Netbeans!
Hi, I need help with a GUI. I am trying to understand it. I am not getting the program to do the calculations when I press the button calculate. I know I am to enter the methods under the ActionPerformed code in Netbeans. I am not sure where I am going wrong, and it is probably something simple. I know the method should include the input I get from each TextField of mortgage, interest rate, and loan term. Can you please try to explain this to me? If I already have the methods, how do I get it to sync with the calculate button and display in another textField. Thanks. My application runs, but it does not calculate and display. I have the clear button working.
private void mortgagecalculatedTextField4ActionPerformed(java.a wt.event.ActionEvent evt) {
double monPay = 0;
System.out.println("" + Math.round(monPay)+ ".");
//calculates the mortgage payment amount based on amount entered by user // TODO add your handling code here:
}
private void calculateButton7ActionPerformed(java.awt.event.Act ionEvent evt) {
double monIntRate = 0.0;//initiates the monthly interest rate
double monPay = 0;//initiates the mortgage payment
double intsPaid = 0;//initiates interest paid
double princPaid = 0;//initiates principal paid
double intRates = 0;
monIntRate = intRates/12;//interest rate divided by 12 months equals the monthly interest rate
int loanTerm = 0;
double totMons = loanTerm*12;//term of loan multiplied by 12 months equals total months of term
double amLoanOne = 0;
double amLoanNxt = amLoanOne;//initiates the amount of loan balance after initial amount
monPay = amLoanOne*monIntRate/(1-(Math.pow((1+monIntRate), (-totMons))));
//calculates the mortgage payment
intsPaid = amLoanOne*monIntRate;
//calculates the interest paid
princPaid = monPay - intsPaid;
//calculates the principal paid
amLoanNxt = amLoanOne - princPaid;
//calculates the amount of loan balance after initial amount // TODO add your handling code here:
}
private void clearjButton8ActionPerformed(java.awt.event.Action Event evt) {
mortgageTextField1.setText("");
loantermTextField2.setText("");
interestrateTextField3.setText("");
mortgagecalculatedTextField4.setText("");
loancalculatedTextField5.setText("");
interestcalculatedTextField6.setText("");
// TODO add your handling code here:
}
private void mortgageTextField1ActionPerformed(java.awt.event.A ctionEvent evt) {
Scanner scan = new Scanner(System.in);
double amLoanOne = scan.nextDouble(); // TODO add your handling code here:
}
private void loantermTextField2ActionPerformed(java.awt.event.A ctionEvent evt) {
Scanner scan = new Scanner(System.in);
double loanTerm = scan.nextDouble(); // TODO add your handling code here:
}
private void interestrateTextField3ActionPerformed(java.awt.eve nt.ActionEvent evt) {
Scanner scan = new Scanner(System.in);
double intRates = scan.nextDouble(); // TODO add your handling code here:
}
private void loancalculatedTextField5ActionPerformed(java.awt.e vent.ActionEvent evt) {
Scanner scan = new Scanner(System.in);
double amLoanOne = scan.nextDouble();
double amLoanNxt = amLoanOne;
System.out.println("" + Math.round(amLoanNxt)+ ".");
//calculates the loan balance based on the amount entered by user // TODO add your handling code here:
}
Code:
private void interestcalculatedTextField6ActionPerformed(java.awt.event.ActionEvent evt) {
Scanner scan = new Scanner(System.in);
double intsPaid = 0;
double monIntRate = 0.0;
double amLoanOne = scan.nextDouble();
intsPaid = amLoanOne*monIntRate;
double amLoanNxt = amLoanOne;
System.out.println("" + Math.round(intsPaid)+ ".");
//calculates the interest paid with interest rate of user input. ex. of .0575
}
GUI build successful!! Thanks!!
Hi, Junky. I got it to run!! Yayyyyyy!! Thanks.