I would like to hide or deactivate a TextField
and its Label
in my JavaFX application.
This is what I tried
myTextField.setVisible(false);
, but it's not working
I use Eclipse V4.5.0 on windows 7 with jfx8 V2.0.0
If you want to erase the content of the label, do: final Label result = ... root. add(result, 0, 1); button.
Making Labels Invisible You can set the value to this property using the setLabelsVisible() method. To make the labels of the current pie chart invisible you need to invoke this method by passing the boolean value false as a parameter.
The <input type="hidden"> defines a hidden input field. A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted.
In FXML, add editable="false" to your TextField tag. Or uncheck the "Editable" checkbox in Scene Builder.
There is difference between hiding and deactivating a TextField in JavaFX.
To Hide :- You need to set the visible property to false.
The possible reason's why its not working in your case is that if you have skipped mentioning the fx:id for your TextField or Label.
To do so just go through the fxml if using and set the fx:id="myTextField" , and then the same code that you have write will start to work.
The same is used to hide any Label.
To Deactivate :- There is a field named as disable just set that disable property to true to disable or deactivate any field.
I understand that you want to hide/show a text field (javaFX), i usually use the same method you mentioned assume that the text field variable name is field then:
to hide it use
field.setVisible(false);
to show it use
field.setVisible(true);
and it works always for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With