posted 22 years ago
Hi Lavanya,
I tried your suggestions, add KeyListener to the comboBox's container, and add one more variable m_ProcessKey. and this is my added code:
/**
* Handle the key pressed event
*/
public void keyPressed(KeyEvent e)
{
if(!m_ProcessKey && e.getKeyCode()==18)//ALT=18
{
m_ProcessKey = true;
}
}
/**
* Handle the key released event
*/
public void keyReleased(KeyEvent e)
{
if(m_ProcessKey && e.getKeyCode()==18)//ALT=18
{
m_ProcessKey = false;
}
}
/**
* Handle the key typed event
*/
public void keyTyped(KeyEvent e)
{
if(m_ProcessKey)
{
if(e.getKeyChar()=='m') // my mnemonic key is M
{
m_Combo.showPopup();
}
else
{
m_Combo.hidePopup();
}
}
}
It works! Thanks a lot.