Start New Discussion within our Software Development Community

Hey all,

I have a simple one I hope. I have created an editable combobox and wanted to clear what is currently displayed in the box once the user sets focus on it either through "tab" or a "mouse click". For example, the combobox would say "Enter a phone number or select your from a list". When the user puts focus on the combobox I want the above string cleared.

So far I have setup the following event.

private void clearPhoneUponFocus(java.awt.event.FocusEvent evt) {
jComboBox1.setModel();
}

I thought I might have to use the setModel method, but can't seem to figure it out. Am I going down the right path? Does anyone have experience doing this and mind lending a hand?

Thanks!

It looks like I figured this out myself. To clear the selection on a combobox, use "setSelectedIndex(-1);"


Hey all,

I have a simple one I hope. I have created an editable combobox and wanted to clear what is currently displayed in the box once the user sets focus on it either through "tab" or a "mouse click". For example, the combobox would say "Enter a phone number or select your from a list". When the user puts focus on the combobox I want the above string cleared.

So far I have setup the following event.

private void clearPhoneUponFocus(java.awt.event.FocusEvent evt) {
jComboBox1.setModel();
}

I thought I might have to use the setModel method, but can't seem to figure it out. Am I going down the right path? Does anyone have experience doing this and mind lending a hand?

Thanks!

This question has already been answered. Start a new discussion instead.