如何使用javafx隐藏或停用TextField和Label [英] How to hide or deactivate a TextField and a Label with javafx
问题描述
我想在我的JavaFX应用程序中隐藏或停用 TextField
及其标签
。
I would like to hide or deactivate a TextField
and its Label
in my JavaFX application.
这就是我试过的事情
myTextField.setVisible(false);
,但它无法正常工作
I在Windows 7上使用Eclipse V4.5.0和jfx8 V2.0.0
I use Eclipse V4.5.0 on windows 7 with jfx8 V2.0.0
推荐答案
在JavaFX中隐藏和停用TextField之间存在差异。
There is difference between hiding and deactivating a TextField in JavaFX.
隐藏: -
您需要将visible属性设置为false。
To Hide :- You need to set the visible property to false.
可能的原因是它在你的情况下不起作用的原因是你跳过提到你的TextField或Label的fx:id。
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.
这样做如果使用并设置fx:id =myTextField,只需浏览fxml,然后你编写的相同代码就会开始工作。
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.
要取消激活: - 有一个名为disable的字段只是将disable属性设置为true以禁用或取消激活任何领域。
To Deactivate :- There is a field named as disable just set that disable property to true to disable or deactivate any field.
这篇关于如何使用javafx隐藏或停用TextField和Label的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!