944,070 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 6507
  • Java RSS
Jul 6th, 2006
0

Clearing a combobox upon selection/focus

Expand Post »
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!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
stharmon is offline Offline
8 posts
since Nov 2004
Jul 7th, 2006
0

Re: Clearing a combobox upon selection/focus

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





Quote originally posted by stharmon ...
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!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
stharmon is offline Offline
8 posts
since Nov 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Wat is method compareTo?
Next Thread in Java Forum Timeline: help needed





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC