Monday, May 12, 2008

Achieving KeyEvent in Editable ComboBox

ComboBoxEditor comboBoxEditor = jComboBox1.getEditor();
JComponent jComponent = (JComponent)comboBoxEditor.getEditorComponent();
if(jComponent instanceof JTextField){
jComponent.addKeyListener(new KeyListener(){
public void keyTyped(KeyEvent e) {

}
public void keyPressed(KeyEvent e) {

}
public void keyReleased(KeyEvent e) {
JOptionPane.showMessageDialog(null, "Iam from ComboBox");
}
});
}

No comments: