micro Posted April 13, 2009 Share Posted April 13, 2009 Right so i created these classes a while ago and now i was asked to implement a gui interface. This is when i discovered that my original code wasn't so great.. LOL So basically my problem is, i am unable to get the endingBalance into the label on the panel.. using getEndBalance() i get a return value of 0.0 So basically it gives me the un initialized value instead of the value that goes to toString.. (same goes for the rest of the "get" methods..) If anyone could help me on this i would really appreciate it. Code: http://www.nopaste.nl/?paste=1370 - AccountInformation http://www.nopaste.nl/?paste=1371 - AccountPanel http://www.nopaste.nl/?p=redirect&id=1372 - RetirementCalculator Ive been stumped for a bit on this one, Thanks again. Link to comment Share on other sites More sharing options...
0 alpha_omega Posted April 13, 2009 Share Posted April 13, 2009 (edited) What does System.out.println("Debugging endBalance:"+ getEndBalance()); return? I guess nothing but still... Edit: You're calling methods without having a receiver. If you want to getEndBalance() then you'll have to tell the VM from which object. Just add values in front of the method. You'll have to loop over the array to get the values of each element of the array if that's what you want to achieve. By the way, Vectors are much more elegant when dealing with arrays of objects: http://java.sun.com/javase/6/docs/api/java/util/Vector.html Edited April 13, 2009 by alpha_omega Link to comment Share on other sites More sharing options...
0 micro Posted April 13, 2009 Author Share Posted April 13, 2009 What does System.out.println("Debugging endBalance:"+ getEndBalance()); return? I guess nothing but still... Edit: You're calling methods without having a receiver. If you want to getEndBalance() then you'll have to tell the VM from which object. Just add values in front of the method. You'll have to loop over the array to get the values of each element of the array if that's what you want to achieve. By the way, Vectors are much more elegant when dealing with arrays of objects: http://java.sun.com/javase/6/docs/api/java/util/Vector.html Nice.. worked great.. Didn't have to loop it i just did values[retirement2 -1].getEndBalance(); because i just wanted the end balance after x many years till retirement.. Again, thanks for the help. Link to comment Share on other sites More sharing options...
0 vks87 Posted April 14, 2009 Share Posted April 14, 2009 Right so i created these classes a while ago and now i was asked to implement a gui interface.This is when i discovered that my original code wasn't so great.. LOL So basically my problem is, i am unable to get the endingBalance into the label on the panel.. using getEndBalance() i get a return value of 0.0 So basically it gives me the un initialized value instead of the value that goes to toString.. (same goes for the rest of the "get" methods..) If anyone could help me on this i would really appreciate it. Code: http://www.nopaste.nl/?paste=1370 - AccountInformation http://www.nopaste.nl/?paste=1371 - AccountPanel http://www.nopaste.nl/?p=redirect&id=1372 - RetirementCalculator Ive been stumped for a bit on this one, Thanks again. Thanks a lot for this useful posts..Hope we ll gain a lot from these links.. Link to comment Share on other sites More sharing options...
Question
micro
Right so i created these classes a while ago and now i was asked to implement a gui interface.
This is when i discovered that my original code wasn't so great.. LOL
So basically my problem is, i am unable to get the endingBalance into the label on the panel..
using getEndBalance() i get a return value of 0.0 So basically it gives me the un initialized value instead of the value that goes to toString..
(same goes for the rest of the "get" methods..)
If anyone could help me on this i would really appreciate it.
Code:
http://www.nopaste.nl/?paste=1370 - AccountInformation
http://www.nopaste.nl/?paste=1371 - AccountPanel
http://www.nopaste.nl/?p=redirect&id=1372 - RetirementCalculator
Ive been stumped for a bit on this one,
Thanks again.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts