Clearing a combobox upon selection/focus

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Nov 2004
Posts: 8
Reputation: stharmon is an unknown quantity at this point 
Solved Threads: 0
stharmon stharmon is offline Offline
Newbie Poster

Clearing a combobox upon selection/focus

 
0
  #1
Jul 6th, 2006
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!
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 8
Reputation: stharmon is an unknown quantity at this point 
Solved Threads: 0
stharmon stharmon is offline Offline
Newbie Poster

Re: Clearing a combobox upon selection/focus

 
0
  #2
Jul 7th, 2006
It looks like I figured this out myself. To clear the selection on a combobox, use "setSelectedIndex(-1);"





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!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 3936 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC