handling jlabel to new cardlayout

Answered

https://stackoverflow.com/questions/48311783/how-to-pass-jlabel-to-another-class

 

Please review stackoverflow(mainly Serge Baranov) link above. i have posted the above as the link as the most common response would be to post the issue on stackoverflow. This was posted almost 6 days ago and i am still no closer to the answer as to why its doing what its doing.

public String amount() {
String gval = lblamnt.getText();
return gval;
}

 

Purchase ppp = new Purchase();

//Temp Variables
private Double cost = Double.parseDouble(ppp.amount());

 

This is the correct syntax. I replicated it in another project.

 

What happens is that the lblamnt.getText() only grabs what was the default defined. Eg. If i set the label as default to nothing, then nothing is passed. If i set it to a number like 109.99 then it will only pass that. But i included buttons to change that label.

 

btn0.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
lblamnt.setText(lblamnt.getText() + "0");
}
});

 

Those are the functions that deal with entering the amount. What am i doing wrong that causes anything i do for changes not get passed?

0
6 comments

Store the value in some common class field instead of the text area or use the original instance of the class. When you call new Purchase(), the new instance of the class is created with the default value. Of course it will not contain the value set in the previously created class instance.

I recommend learning some basic OOP before you start writing applications in Java, this will answer most of your common questions.

Once again, this support channel is for IntelliJ IDEA product questions, not Java programming questions.

0
Avatar
Permanently deleted user

You mean this series https://www.youtube.com/watch?v=0NPR8GFHNmE ??

Yea watched it already. guess what shocker nothing new.

posting code is more useful than words. If i have a visual representation along with the explanation i learn so much better. Especially if its specifically to this situation.

I tried posting this on stack overflow and their comments was nothing new that i havent tried. So stackoverflow isnt working out.

I am frustrated over something so trivial and simple. And dont forget i started a new project and guess what? Shocker i was able to do it just fine. So its not that i dont know how to program and instantiate/declare variables.

A specific example along with a very brief explanation will do more.

0

Since it works in your new project, you can now compare it with the old one and find out what you did differently this time.

0

And if you want to get help at StackOverflow, the best way is to share the .zip code of the example that doesn't work for you. This way others will not waste time recreating the project and will be able to help you much faster. If you don't understand what others suggest you to do, kindly ask them to provide you the complete examples based on your sample.

0
Avatar
Permanently deleted user

i did in the past and i quote"No one is going to download a zip file from an unknown ip address" I even put it on megaupload and no one downloaded it. You know for a site for programming people are quite paranoid.

 

Also i did compare and i could not detect anything that was different, hence my great deal of frustration.

 

https://mega.nz/#!tZoQUByC

https://24.57.9.199/wallettemplate.rar

To review the files.

Also for assistance if you have a bitcoin wallet feel free to include that there so i can send a few bucks.

0

Put the project source code on GitHub and provide a link to the project.

IP link doesn't work, mega.nz requires the key to download.

0

Please sign in to leave a comment.