Java Swing Currency Converter

Posted on  by  admin

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.

  1. Java Swing Currency Converter Download

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.

mKorbel
105k14 gold badges112 silver badges275 bronze badges
ay lmaoay lmao

1 Answer

Converter

You 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

Java Swing Currency Converter Download

2,75512 gold badges48 silver badges70 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged javaswingif-statementconverterjcombobox or ask your own question.

Coments are closed
Scroll to top