mccob mccob - 7 months ago 11
Java Question

JavaFx setText the field as an int

How can I set a textfield as a int type?
Like if i had this line of code:

appointmentText.setText(pa.getindex());


if
appointmentText
is the textField and
pa.getindex();
gets an int type from another class

Answer

Use String.valueOf()

appointmentText.setText(String.valueOf(pa.getindex());

By the way, getindex() should be getIndex() following the camel-case naming convention.

Comments