Example text in JTextField

后端 未结 7 2065
独厮守ぢ
独厮守ぢ 2021-01-18 05:15

I am looking for a way to put example text into a swing JTextField and have it grayed out. The example text should then disappear as soon as any thing is entered into that t

7条回答
  •  再見小時候
    2021-01-18 05:41

    You can't do that with a plain text field, but you can put a disabled JLabel on top of the JTextField and hide it if the text field gets the focus.

提交回复
热议问题