Java AutoConversion textfield component

AutoConversion textfield component:

If you drive a motorized stage of a microscope you often have to handle coordinates in a unit like millimeter [mm]. But it might happen that the sample in your microscope is only in the range of microns [µm].

So would it not be nice to directly type in the coordinates in µm and the textfield would automaticaly convert the unit into [mm] ?

This would increase the workflow a lot because you do not have to think about conversion of units. There seems to be countries that are using inches and people living there might like to type in coordinates in inches instead of millimeters..etc…

For this reason i created a little component that extends a standard javax.swing.JTextField and is now able to do the conversion. You could also use the conversion alone without the textfield to create some kind of unit converter…it’s up to you.

Here are a few screenshots of a demo app that uses the component:

#1 Step

#3 Step#2 Step

So you could type in a value with the unit of your choice and after leaving the field or pressing enter the value will be converted into the textfields „base unit“.

The upper combobox will select the type of unit you would like to use (it supports angle, area, length, mass, temperature, time at the moment but one could easily add more units to it).

The middle combobox will select the current base unit for the textfield.

The lower combobox will adjust the number of decimals for the textfield.

Because it displays the unit directly in the textfield there’s no need for a additional label for the unit.

You also might check this little video

Well this is nothing very fancy or gui related but it was very useful for me so i decided to share it with you… ConversionField.zip

 

follow me on twitter if you like…

 

One thought to “Java AutoConversion textfield component”

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.