Key events are not triggered in the window itself, but in its editor. You need to add keyListener to the JComboBox editor, and not to the field directly:
comboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent evt)
{
if(evt.getKeyCode() == KeyEvent.VK_ENTER)
{
System.out.println("Pressed");
}
}
});
Edit: fixed method call.
source
share