问题
This has been addressed for C# in here by using jQuery or by changing dynamically the "input" type. The jQuery option is probably overkilling in GWT and the change of input type I think is not possible. What is the best way to do it using GWT?
is it really necessary to do two inputs (one for the watermark as TextInput and another one for the password as Password and switch between them?)
回答1:
The easiest is to set the element's placeholder: passwd.getElement().setProperty("watermark")
. Otherwise, use a label/span that you position on top of the input and show/hide as the field gets focused/blurred.
来源:https://stackoverflow.com/questions/10167116/watermark-on-password-text-input-using-gwt