Hello Everyone.
So I have been refreshing myself on Java. To do this, I have been doing a self-assigned Java project which is a GUI unit converter program using Netbeans, Java8, and JavaFX. A had some tutorial help. Some road bumps, but I managed to solve them.
So far, I have aiming to convert to basic length units.(Meters and Feet) with two text fields that have combo boxes that allow to choose between the two units(in future, more) with another combo box that will allows one to choose between types of units(length, weight, volume.) that will change that unit the below combo boxes
So it seems to me that I have got everything in order to test my first basic unit conversion.
In case in becomes relevant(I suspect it is part of problem) . How the unit converter works is by using a base unit(meter in the case of length) and convert all queries to that unit before converting from that unit to the desired unit. I.E To convert inches to feet, inches is first converted to meters, then then result in meters is converted to feet.
So it seems to me that I have got everything in order to test my first basic unit conversion.
I type in 1 and 1 appears in the left text field(meters to feet for now), but the right text field(feet) does not fill with a conversion result. I type in another 1 into the left text field, making the number appear to be 11. The right text field finally spits out an answer. But instead of being the correct result(11 meters = 36,089 feet) the result is (1 meter = 3,2808) which means that the logic code ignores the first number.
I figured out that the field only outputs the correct results when I type a .full stop. at the end of the number I.E to make sure that ‘114’ is not only accepted as ‘14’ you have type in ‘114.’ I can also then remove the full stop and the right field will not change, but to have more number added to query, you have to add them then type in a full stop again. I have been using BigDecimal, so that might be part of the problem
There is also the problems that if I type in the right (there is supposed to be a two way conversion system) then it still ignores the first number, but when I also type more numbers in right text field, then only the right text field fills with numbers, like the result is being outputted to the same field it being typed in.
Another problem is in the if-else statement where the code that wipes both sides when the text field is cleared[isEmpty] is triggered into action by just typing in the text field. Though it just triggers the systems printout part of the statement and not the wiping of the text fields.
Any help will be appreciated.
Please find the code attached to post below