I'm creating a currency converter and the problem that's been bugging me is that every time I run the program, I think a new instance of JLabel is being created, when in fact I need the one that is already set to be updated. I have tried what seems like everything to fix this but I can't figure it out.
I click in the digits I like, using a keypad of JButtons which update the default Label of "0" to the digits I have clicked, but when I click the "Euro" button it is meant to update the JLabel with the converted currency.
I know that the currency is being converted successfully as I have print statements showing me, but I can not get it to update the JLabel in my GUI class.
In case I understood correctly, an approach here is to add a listener to the JButton class instance. In the listener you should use getText() method to get String from the button. After that you should use the String in setText() to set up the String in the JLabel instance.
Both myButton and myLabel variables must be marked as final.