edvin / tornadofx

Lightweight JavaFX Framework for Kotlin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rebinding TextField

yamert89 opened this issue · comments

I try reuse textField with different converters.
Simplify model of code looks that

val field: TextField by fxid()

field.bind(SimpleIntegerProperty(1), IntegerStringConverter())

then i need bind this field with float property

field.bind(SimpleFloatProperty(2,1f), FloatStringConverter())

and get NumberFormatException

java.lang.NumberFormatException: For input string: "2,1"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.valueOf(Integer.java:766)
	at javafx.util.converter.IntegerStringConverter.fromString(IntegerStringConverter.java:49)

Can i do use new converter?

replace , -> .

if you do not specify the converter, then is deduced type - NumberProperty (using NumberStringConverter). Tornadofx 2

replace , -> .

already did it. StackTrace shows that Integer.parseInt run where not should be.

if you do not specify the converter, then is deduced type - NumberProperty (using NumberStringConverter). Tornadofx 2

IntegerProperty and FloatProperty are locate in view models. I don't understand how to cast the type yet. I have not used tornadofx 2 yet. I will do

if you use the converter explicitly, then it calls its name. Alas, it is not clear yet why you are getting such an error, you could give a minimal example where the question is producing this error. Also include the version of tornadofx and kotlin

I did not deal with this problem, but simply changed the architecture of the view models. Thanks.