Example usage for java.awt.event ActionEvent getModifiers

List of usage examples for java.awt.event ActionEvent getModifiers

Introduction

In this page you can find the example usage for java.awt.event ActionEvent getModifiers.

Prototype

public int getModifiers() 

Source Link

Document

Returns the modifier keys held down during this action event.

Usage

From source file:org.yccheok.jstock.gui.AutoCompleteJComboBox.java

private ActionListener getActionListener() {
    return new ActionListener() {
        @Override/*from  w ww  .j  ava  2s  . c om*/
        public void actionPerformed(ActionEvent e) {
            /* Handle mouse clicked. */
            if ((e.getModifiers()
                    & java.awt.event.InputEvent.BUTTON1_MASK) == java.awt.event.InputEvent.BUTTON1_MASK) {
                final Object object = AutoCompleteJComboBox.this.getEditor().getItem();
                /* Let us be extra paranoid. */
                if (object instanceof DispType) {
                    DispType lastEnteredDisp = (DispType) object;
                    AutoCompleteJComboBox.this.dispSubject.notify(AutoCompleteJComboBox.this, lastEnteredDisp);
                } else if (object instanceof StockInfo) {
                    // From our offline database.
                    StockInfo lastEnteredStockInfo = (StockInfo) object;
                    AutoCompleteJComboBox.this.stockInfoSubject.notify(AutoCompleteJComboBox.this,
                            lastEnteredStockInfo);
                } else {
                    assert (false);
                }

                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        // We schedule the below actions in GUI event queue,
                        // so that DocumentListener will not be triggered.
                        // But I am not sure why.
                        AutoCompleteJComboBox.this.getEditor().setItem(null);
                        AutoCompleteJComboBox.this.hidePopup();
                        AutoCompleteJComboBox.this.removeAllItems();
                    }
                });
            }
        }
    };
}