I'm trying to reproduce the behavior of the search field of Firefox or Safari, or the search field of stackoverflow.com
on the top right of this page.
I mean, when there is no text on the editable JComboBox
, an instruction text is displayed, like "Type here"
or whatever. When the JComboBox
is focused the text is removed. If the focus is lost with no text typed, the instruction text comes back.
Note:
Check out Text Prompt for a more complete implementation of the code below with more features.
Here's something simple I threw together. I'm sure you can tidy it up. Since the code works on a JTextField, you would need to get the editor of the combobox. I no nothing about how Glazed lists is implemented so I'm just guessing it will work for you.
Its called a waterMark. jQuery has one. I've never tired to apply a watermark to a jComboBox.
Good luck