I'm trying to make a simple unit Mass conversion GUI application. I have two combo boxes to select units from, an input box to input a number to convert, and text to display the result of the conversion.
In this example we are going to implement Currency Conversion Using Java. For converting money from one currency to another, we need to find the exchange rate between that currencies.
My problem right now is that I'm trying to get the actual push of the button to initiate the calculations, but instead it's getting initiated when I select anything from the list
dropdown combobox. I could enter a number into the textbox, select a unit from the 2nd combo box, and then select something from the first combo box, and it will work because it has the variables it needs.
My code is right below.
mKorbelYou don't want to have the action listener on both lists and the button. Instead, just have it on the button.
The way you have it, the calculation will be performed every time either of the lists is changes (as you've observed). If it's just on the button, it will only be called when the button is clicked.
chamachama