This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Set text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Set text" Watch "Set text" New topic
Author

Set text

Patty Edens
Greenhorn

Joined: May 20, 2004
Posts: 6
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);
David Ng
Greenhorn

Joined: May 11, 2004
Posts: 12
It would help if you post some detail about the PaymentObject.
Patty Edens
Greenhorn

Joined: May 20, 2004
Posts: 6
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
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: May 20, 2004
Posts: 6
That worked - Thank you!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Set text