Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Set text

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm having trouble with two lines of set.text code. The error message is cannot resolve symbol which I know this means the code cannot identify what this meand - my problem is I'm not sure why. I have the variables identified. I did remove some Decimal.format code because at this stage it wasn't needed and I couldnt get it to work. Here's a snippet of code - Hope someone can help.

double loanAmt = Double.parseDouble(PaymentObject.Mortgage.getText ());
double numOfPayments = Double.parseDouble(PaymentObject.term.getText())*12;
double rateAmt = Double.parseDouble(PaymentObject.rate.getText())/100/12;
double payAmt = (loanAmt*rateAmt) / (1-(Math.pow((1+rateAmt),
(-1*numOfPayments))));
PaymentObject.paymentsNo.setText(numOfPayments);
PaymentObject.amountPayment.setText(payAmt);
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help if you post some detail about the PaymentObject.
 
Patty Edens
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sorry about that! Here's all the code. PaymentObject is being used to tie the gui program and event program together.

//import necessary classes
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class MortgageEventWk4 implements ActionListener
{

//links this event class with the main classes and names the object
Pattys_Mortgage_Wk4 PaymentObject;
Thread Mortgage;

//constructor method - creates the ojbect based on the methods
//within main class
public MortgageEventWk4(Pattys_Mortgage_Wk4 in)
{
PaymentObject = in;
} //end of method


//declare variables
//double amountLoan;
//double amountNoPayments;
//double rateAmount;
//double payAmount;
double amountPayment;
double paymentsNo;

//Create the method that will call the event to initialize the
//ActionListener event. Determine the event's source and state.
public void actionPerformed(ActionEvent event)
{
//process the user action
String command = event.getActionCommand();
if (command == "Reset")
reset();
if (command == "Pause")
pause();
if (command == "Continue")
cont();
if (command == "7 Years at 5.35%")
{
//hold for correct code
}
if (command == "15 Years at 5.5%")
{
//hold for correct code
}
if (command == "30 Years at 5.75%")
{
//hold for correct code
}
}//end method



void reset()
{
PaymentObject.pause.setEnabled(true);
PaymentObject.cont.setEnabled(true);
PaymentObject.reset.setEnabled(true);
PaymentObject.amount.setText(null);
PaymentObject.rate.setText(null);
PaymentObject.term.setText(null);
PaymentObject.paymentsNo.setText(null);
PaymentObject.amountPayment.setText(null);
PaymentObject.manualEntry.setSelected(false);
PaymentObject.menuEntry.setSelected(false);
}//end of method

void cont()
{
PaymentObject.pause.setEnabled(true);
PaymentObject.cont.setEnabled(false);
PaymentObject.reset.setEnabled(true);
}//end of method

void pause()
{
PaymentObject.pause.setEnabled(false);
PaymentObject.cont.setEnabled(true);
PaymentObject.reset.setEnabled(true);
}//end of method


//run method - main part of code
public void run()
{
Thread TheThread = Thread.currentThread();

while (Mortgage == TheThread)
{
double loanAmt = Double.parseDouble(PaymentObject.Mortgage.getText());
double numOfPayments = Double.parseDouble(PaymentObject.term.getText())*12;
double rateAmt = Double.parseDouble(PaymentObject.rate.getText())/100/12;
double payAmt = (loanAmt*rateAmt) / (1-(Math.pow((1+rateAmt),
(-1*numOfPayments))));
PaymentObject.paymentsNo.setText(numOfPayments);
PaymentObject.amountPayment.setText(payAmt);
}//end method

}//end of method

}//end of method
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably the setText() method requires a String and you're passing it a double.


PaymentObject.paymentsNo.setText(String.valueOf(numOfPayments));

or (the shortcut)
PaymentObject.paymentsNo.setText(""+numOfPayments);
 
Patty Edens
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked - Thank you!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic