Here is one way that should work (hopefully):
JComboBox jComboBox = new JComboBox();
EventList<String> eventList = new BasicEventList<String>();
AutoCompleteSupport support = AutoCompleteSupport.install(jComboBox, eventList);
jComboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
System.out.println(((JTextField) jComboBox.getEditor().getEditorComponent()).getText());
}
}
});
Hope this helps,
Holger
> What is the correct way to listen for the enter key in AutoComplete
> JComboBox?
>
> I want to save the entered string, when the user press enter...
>
> my code:
>
> JComboBox jComboBox = new JComboBox();
> EventList<String> eventList = new BasicEventList<String>();
> AutoCompleteSupport support = AutoCompleteSupport.install(jComboBox,
> eventList);
>
________________________________________________________________
Neu: WEB.DE Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!*
http://produkte.web.de/go/02/---------------------------------------------------------------------
To unsubscribe, e-mail:
users-unsubscribe@...
For additional commands, e-mail:
users-help@...