Jcombobox
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kayal_Selvaraj
Posted On:   Sunday, October 21, 2001 11:40 PM

I am writing an applet which has a drop-down (JComboBox).

My requirement is to make the drop-down self refreshing. That is if the user types in 'AD' in the JComboBox, the ComboBox should open up and display all the entries starting with 'AD', so that the user can select what he requires.

How can this be done? Do we have any property of JComboBox which has to be set or some code has to be written for it?

Re: Jcombobox

Posted By:   ryan_wexler  
Posted On:   Monday, October 22, 2001 11:10 AM

I think this will get you in the right direction.
Try adding a key listener on the editable area of the jcombo box.
JComboBox somejcombobox = new JComboBox();
JTextField hidden = (JTextField)somejcombobox.getEditor().getEditorComponent();
hidden.addKeyListener(new java.awt.event.KeyAdapter()
{
public void keyTyped(KeyEvent e)
{
parse the text in hidden if return character there - open the jcombo box at the specified place
}
When text is typed in jtextfield the key typed action will be triggered. If you want you can search for the return character in the key listener and if you find it open the box if not just do nothing
About | Sitemap | Contact