Updating text on JFrame depending on ActionListener
-
27-09-2019 - |
Question
This is a result of ActionListener. Depending on what he chooses in the Combo Box it returns a price. I just want it as a simple $39.99. Nothing more.
I have the
packageIndex = packageChoice.getSelectedIndex();
All the prices are in an array:
String[] prices = {"49.99, 39.99, 34.99, 99.99"}
Now I need to know how to pull the price out and display it and be able to work with the data later on. But I don't know how to pull a piece of the array out and set it to another variable.
Solution
If you declare the array like:
String[] prices = {"49.99", "39.99", "34.99", "99.99"}
then you can get individual prices using:
String price = prices[packageIndex];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow