i've been making simple javafx 2 gui application and found that prompttext in textfield of javafx 2 hides as soon as the textfield gets focus.
this wasn't this way some updates back. prior to this update, the textfield showed the prompttext until some text is typed into.
this isn't good and really need a workaround for this.
I just solved this same issue by applying particular CSS rules to text inputs. Here's what I used (which should apply to all text-inputs)
Erem Boto
's answer is just fine and should solve your problem!Please see my answer here to see how to solve the problem if you use proper Java code (no FXML and CSS file).
(And also how to get the other behavior back).
In short, this is the solution:
In case your application interface is written using proper Java code.
Java Code:
Where
textField
is your TextField component.And in case your application interface is written using FXML and CSS, add the following to your CSS file.
JavaFX FXML (CSS):