use of javax.swing.event.PopupMenuListener in project knime-core by knime.
the class SQLTypeCellEditor method initializeComboBox.
/**
* Initializes the underlying JComboBox used as cell editor
*
* @param comboBox
*/
private void initializeComboBox(final JComboBox<String> comboBox) {
comboBox.setEditable(true);
comboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent ev) {
if (ev.getActionCommand().equals("comboBoxEdited")) {
String elem = ((String) comboBox.getEditor().getItem()).trim();
m_table.setValueAt(elem, m_row, m_col);
addElement(m_relatedKey.toString(), elem);
}
}
});
comboBox.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(final PopupMenuEvent e) {
comboBox.getEditor().getEditorComponent().setEnabled(false);
}
@Override
public void popupMenuWillBecomeInvisible(final PopupMenuEvent e) {
comboBox.getEditor().getEditorComponent().setEnabled(true);
}
@Override
public void popupMenuCanceled(final PopupMenuEvent e) {
}
});
}
Aggregations