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:javazoom.jlgui.player.amp.equalizer.ui.EqualizerUI.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
    // On/Off/* w w  w  .j a  va2s .co  m*/
    if (cmd.equals(PlayerActionEvent.ACEQONOFF)) {
        if (ui.getAcEqOnOff().isSelected()) {
            config.setEqualizerOn(true);
        } else {
            config.setEqualizerOn(false);
        }
        synchronizeEqualizer();
    }
    // Auto
    else if (cmd.equals(PlayerActionEvent.ACEQAUTO)) {
        if (ui.getAcEqAuto().isSelected()) {
            config.setEqualizerAuto(true);
        } else {
            config.setEqualizerAuto(false);
        }
    }
    // Presets
    else if (cmd.equals(PlayerActionEvent.ACEQPRESETS)) {
        if (e.getModifiers() == MouseEvent.BUTTON1_MASK) {
            mainpopup.show(this, ui.getAcEqPresets().getLocation().x, ui.getAcEqPresets().getLocation().y);
        }
    } else if (cmd.equals("Normal")) {
        updateSliders(PRESET_NORMAL);
        synchronizeEqualizer();
    } else if (cmd.equals("Classical")) {
        updateSliders(PRESET_CLASSICAL);
        synchronizeEqualizer();
    } else if (cmd.equals("Club")) {
        updateSliders(PRESET_CLUB);
        synchronizeEqualizer();
    } else if (cmd.equals("Dance")) {
        updateSliders(PRESET_DANCE);
        synchronizeEqualizer();
    } else if (cmd.equals("Full Bass")) {
        updateSliders(PRESET_FULLBASS);
        synchronizeEqualizer();
    } else if (cmd.equals("Full Bass & Treble")) {
        updateSliders(PRESET_FULLBASSTREBLE);
        synchronizeEqualizer();
    } else if (cmd.equals("Full Treble")) {
        updateSliders(PRESET_FULLTREBLE);
        synchronizeEqualizer();
    } else if (cmd.equals("Laptop")) {
        updateSliders(PRESET_LAPTOP);
        synchronizeEqualizer();
    } else if (cmd.equals("Live")) {
        updateSliders(PRESET_LIVE);
        synchronizeEqualizer();
    } else if (cmd.equals("Party")) {
        updateSliders(PRESET_PARTY);
        synchronizeEqualizer();
    } else if (cmd.equals("Pop")) {
        updateSliders(PRESET_POP);
        synchronizeEqualizer();
    } else if (cmd.equals("Reggae")) {
        updateSliders(PRESET_REGGAE);
        synchronizeEqualizer();
    } else if (cmd.equals("Rock")) {
        updateSliders(PRESET_ROCK);
        synchronizeEqualizer();
    } else if (cmd.equals("Techno")) {
        updateSliders(PRESET_TECHNO);
        synchronizeEqualizer();
    }
}

From source file:javazoom.jlgui.player.amp.PlayerUI.java

/**
 * Process action event.//  ww w. jav a 2s  .  c  om
 * @param e
 */
public void processActionEvent(ActionEvent e) {
    String cmd = e.getActionCommand();
    log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
    // Preferences.
    if (cmd.equalsIgnoreCase(PlayerActionEvent.MIPREFERENCES)) {
        processPreferences(e.getModifiers());
    }
    // Skin browser
    else if (cmd.equals(PlayerActionEvent.MISKINBROWSER)) {
        processSkinBrowser(e.getModifiers());
    }
    // Jump to file
    else if (cmd.equals(PlayerActionEvent.MIJUMPFILE)) {
        processJumpToFile(e.getModifiers());
    }
    // Stop
    else if (cmd.equals(PlayerActionEvent.MISTOP)) {
        processStop(MouseEvent.BUTTON1_MASK);
    }
    // Load skin
    else if (e.getActionCommand().equals(PlayerActionEvent.MILOADSKIN)) {
        File[] file = FileSelector.selectFile(loader, FileSelector.OPEN, false,
                ui.getResource("skin.extension"), ui.getResource("loadskin.dialog.filtername"),
                new File(config.getLastDir()));
        if (FileSelector.getInstance().getDirectory() != null)
            config.setLastDir(FileSelector.getInstance().getDirectory().getPath());
        if (file != null) {
            String fsFile = file[0].getName();
            ui.setPath(config.getLastDir() + fsFile);
            loadSkin();
            config.setDefaultSkin(ui.getPath());
        }
    }
    // Shuffle
    else if (cmd.equals(PlayerActionEvent.ACSHUFFLE)) {
        if (ui.getAcShuffle().isSelected()) {
            config.setShuffleEnabled(true);
            if (playlist != null) {
                playlist.shuffle();
                playlistUI.initPlayList();
                // Play from the top
                PlaylistItem pli = playlist.getCursor();
                setCurrentSong(pli);
            }
        } else {
            config.setShuffleEnabled(false);
        }
    }
    // Repeat
    else if (cmd.equals(PlayerActionEvent.ACREPEAT)) {
        if (ui.getAcRepeat().isSelected()) {
            config.setRepeatEnabled(true);
        } else {
            config.setRepeatEnabled(false);
        }
    }
    // Play file
    else if (cmd.equals(PlayerActionEvent.MIPLAYFILE)) {
        processEject(MouseEvent.BUTTON1_MASK);
    }
    // Play URL
    else if (cmd.equals(PlayerActionEvent.MIPLAYLOCATION)) {
        processEject(MouseEvent.BUTTON3_MASK);
    }
    // Playlist menu item
    else if (cmd.equals(PlayerActionEvent.MIPLAYLIST)) {
        ui.getAcPlaylist().setSelected(miPlaylist.getState());
        togglePlaylist();
    }
    // Playlist toggle button
    else if (cmd.equals(PlayerActionEvent.ACPLAYLIST)) {
        togglePlaylist();
    }
    // EqualizerUI menu item
    else if (cmd.equals(PlayerActionEvent.MIEQUALIZER)) {
        ui.getAcEqualizer().setSelected(miEqualizer.getState());
        toggleEqualizer();
    }
    // EqualizerUI
    else if (cmd.equals(PlayerActionEvent.ACEQUALIZER)) {
        toggleEqualizer();
    }
    // Exit player
    else if (cmd.equals(PlayerActionEvent.ACEXIT)) {
        closePlayer();
    }
    // Minimize
    else if (cmd.equals(PlayerActionEvent.ACMINIMIZE)) {
        loader.minimize();
    }
    // Eject
    else if (cmd.equals(PlayerActionEvent.ACEJECT)) {
        processEject(e.getModifiers());
    }
    // Play
    else if (cmd.equals(PlayerActionEvent.ACPLAY)) {
        processPlay(e.getModifiers());
    }
    // Pause
    else if (cmd.equals(PlayerActionEvent.ACPAUSE)) {
        processPause(e.getModifiers());
    }
    // Stop
    else if (cmd.equals(PlayerActionEvent.ACSTOP)) {
        processStop(e.getModifiers());
    }
    // Next
    else if (cmd.equals(PlayerActionEvent.ACNEXT)) {
        processNext(e.getModifiers());
    }
    // Previous
    else if (cmd.equals(PlayerActionEvent.ACPREVIOUS)) {
        processPrevious(e.getModifiers());
    }
}

From source file:de.huxhorn.lilith.swing.ApplicationPreferences.java

public boolean isReplacingOnApply(ActionEvent event) {
    // TODO make default behavior configurable.
    boolean result = false;
    if (event == null || (ActionEvent.SHIFT_MASK & event.getModifiers()) == 0) {
        result = true;/* ww w  .j  a  va  2 s  .  c o  m*/
    }
    return result;
}

From source file:org.bitbucket.mlopatkin.android.logviewer.widgets.UiHelper.java

/**
 * Creates a wrapper around an existing action of the component to be used
 * in menus./*  ww w . j  a va2  s.  co  m*/
 * 
 * @param c
 *            base component
 * @param actionKey
 *            key in the component's ActionMap
 * @param caption
 *            caption of the action wrapper
 * @param acceleratorKey
 *            accelerator key of the action wrapper
 * @return action that translates its
 *         {@link Action#actionPerformed(ActionEvent)} to the underlaying
 *         existing action.
 */
public static Action createActionWrapper(final JComponent c, final String actionKey, String caption,
        final String acceleratorKey) {
    final Action baseAction = c.getActionMap().get(actionKey);
    Action result = new AbstractAction(caption) {
        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(acceleratorKey));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            ActionEvent newEvent = new ActionEvent(c, e.getID(), actionKey, e.getWhen(), e.getModifiers());
            baseAction.actionPerformed(newEvent);
        }

        @Override
        public void setEnabled(boolean newValue) {
            super.setEnabled(newValue);
            baseAction.setEnabled(newValue);
        }
    };
    return result;
}

From source file:org.executequery.gui.browser.FindAction.java

public void actionPerformed(ActionEvent e) {
    if (e.getSource() == searchField)
        popup.setVisible(false);/*from  w  w w  .  j  a v  a2s. c o m*/
    else {
        //         component = (JComponent) e.getSource();
        ignoreCase = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0;

        searchField.removeActionListener(this);
        searchField.removeKeyListener(this);
        searchField.getDocument().removeDocumentListener(this);
        initSearch(e);
        searchField.addActionListener(this);
        searchField.addKeyListener(this);
        searchField.getDocument().addDocumentListener(this);

        clearResultsListData();

        Rectangle rect = component.getVisibleRect();
        //            popup.show(comp, rect.x = 5, rect.y - popup.getPreferredSize().height
        //                    - 10);
        popup.show(component, rect.x = 80, rect.y);
        searchField.requestFocus();
    }
}

From source file:org.jajuk.ui.views.CoverView.java

@Override
public void actionPerformed(final ActionEvent e) {
    if (e.getSource() == jcbAccuracy) {
        handleAccuracy();/*from  ww w.  j a  va 2  s.co m*/
    } else if (e.getSource() == jbPrevious) { // previous : show a
        handlePrevious();
    } else if (e.getSource() == jbNext) { // next : show a worse cover
        handleNext();
    } else if (e.getSource() == jbDelete) { // delete a local cover
        handleDelete();
    } else if (e.getSource() == jbDefault) {
        handleDefault();
    } else if ((e.getSource() == jbSave)
            && ((e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK)) {
        // save a file as... (can be local now)
        handleSaveAs();
    } else if (e.getSource() == jbSave) {
        handleSave();
    }
}

From source file:org.pentaho.reporting.designer.core.actions.global.ScreenCaptureAction.java

public void actionPerformed(final ActionEvent e) {
    saveScreenShot(e.getModifiers());
}

From source file:org.rdv.datapanel.DigitalTabularDataPanel.java

private void addColumn() {
    if (columnGroupCount == MAX_COLUMN_GROUP_COUNT) {
        return;/*from   w  ww.  jav a2  s . com*/
    }

    if (columnGroupCount != 0) {
        panelBox.add(Box.createHorizontalStrut(7));
    }

    final int tableIndex = columnGroupCount;

    final DataTableModel tableModel = new DataTableModel();
    final JTable table = new JTable(tableModel);

    table.setDragEnabled(true);
    table.setName(DigitalTabularDataPanel.class.getName() + " JTable #" + Integer.toString(columnGroupCount));

    if (showThresholdCheckBoxGroup.isSelected()) {
        tableModel.setThresholdVisible(true);
    }

    if (showMinMaxCheckBoxGroup.isSelected()) {
        tableModel.setMaxMinVisible(true);

        table.getColumn("Min").setCellRenderer(doubleCellRenderer);
        table.getColumn("Max").setCellRenderer(doubleCellRenderer);
    }

    table.getColumn("Value").setCellRenderer(dataCellRenderer);

    tables.add(table);
    tableModels.add(tableModel);

    JScrollPane tableScrollPane = new JScrollPane(table);
    panelBox.add(tableScrollPane);

    // popup menu for panel
    JPopupMenu popupMenu = new JPopupMenu();

    final JMenuItem copyMenuItem = new JMenuItem("Copy");
    copyMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            TransferHandler.getCopyAction().actionPerformed(
                    new ActionEvent(table, ae.getID(), ae.getActionCommand(), ae.getWhen(), ae.getModifiers()));
        }
    });
    popupMenu.add(copyMenuItem);

    popupMenu.addSeparator();

    JMenuItem printMenuItem = new JMenuItem("Print...");
    printMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                table.print(JTable.PrintMode.FIT_WIDTH);
            } catch (PrinterException pe) {
            }
        }
    });
    popupMenu.add(printMenuItem);
    popupMenu.addSeparator();

    final JCheckBoxMenuItem showMaxMinMenuItem = new JCheckBoxMenuItem("Show min/max columns", false);
    showMaxMinMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setMaxMinVisible(showMaxMinMenuItem.isSelected());
        }
    });
    showMinMaxCheckBoxGroup.addCheckBox(showMaxMinMenuItem);
    popupMenu.add(showMaxMinMenuItem);

    final JCheckBoxMenuItem showThresholdMenuItem = new JCheckBoxMenuItem("Show threshold columns", false);
    showThresholdMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setThresholdVisible(showThresholdMenuItem.isSelected());
        }
    });
    showThresholdCheckBoxGroup.addCheckBox(showThresholdMenuItem);
    popupMenu.add(showThresholdMenuItem);

    popupMenu.addSeparator();

    JMenuItem blankRowMenuItem = new JMenuItem("Insert blank row");
    blankRowMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tableModel.addBlankRow();
        }
    });
    popupMenu.add(blankRowMenuItem);

    final JMenuItem removeSelectedRowsMenuItem = new JMenuItem("Remove selected rows");
    removeSelectedRowsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            removeSelectedRows(tableIndex);
        }
    });
    popupMenu.add(removeSelectedRowsMenuItem);

    popupMenu.addSeparator();

    JMenu numberOfColumnsMenu = new JMenu("Number of columns");
    numberOfColumnsMenu.addMenuListener(new MenuListener() {
        public void menuSelected(MenuEvent me) {
            JMenu menu = (JMenu) me.getSource();
            for (int j = 0; j < MAX_COLUMN_GROUP_COUNT; j++) {
                JMenuItem menuItem = menu.getItem(j);
                boolean selected = (j == (columnGroupCount - 1));
                menuItem.setSelected(selected);
            }
        }

        public void menuDeselected(MenuEvent me) {
        }

        public void menuCanceled(MenuEvent me) {
        }
    });

    for (int i = 0; i < MAX_COLUMN_GROUP_COUNT; i++) {
        final int number = i + 1;
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(Integer.toString(number));
        item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                setNumberOfColumns(number);
            }
        });
        numberOfColumnsMenu.add(item);
    }
    popupMenu.add(numberOfColumnsMenu);

    popupMenu.addPopupMenuListener(new PopupMenuListener() {
        public void popupMenuWillBecomeVisible(PopupMenuEvent arg0) {
            boolean anyRowsSelected = table.getSelectedRowCount() > 0;
            copyMenuItem.setEnabled(anyRowsSelected);
            removeSelectedRowsMenuItem.setEnabled(anyRowsSelected);
        }

        public void popupMenuWillBecomeInvisible(PopupMenuEvent arg0) {
        }

        public void popupMenuCanceled(PopupMenuEvent arg0) {
        }
    });

    // set component popup and mouselistener to trigger it
    table.setComponentPopupMenu(popupMenu);
    tableScrollPane.setComponentPopupMenu(popupMenu);

    panelBox.revalidate();

    columnGroupCount++;

    properties.setProperty("numberOfColumns", Integer.toString(columnGroupCount));
}

From source file:org.wings.SAbstractButton.java

/**
 * Fire an ActionEvent at each registered listener.
 *
 * @param event supplied ActionEvent/*from w ww.j a va  2 s . c om*/
 */
protected void fireActionPerformed(ActionEvent event) {
    // Guaranteed to return a non-null array
    Object[] listeners = getListenerList();
    ActionEvent e = null;
    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == ActionListener.class) {
            if (e == null) {
                String actionCommand = event.getActionCommand();
                if (actionCommand == null) {
                    actionCommand = getActionCommand();
                }
                e = new ActionEvent(SAbstractButton.this, ActionEvent.ACTION_PERFORMED, actionCommand,
                        event.getWhen(), event.getModifiers());
            }
            ((ActionListener) listeners[i + 1]).actionPerformed(e);
        }
    }
}

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

private ActionListener getActionListener() {
    return new ActionListener() {
        @Override//from ww w. j  av  a  2 s.c o m
        public void actionPerformed(ActionEvent e) {
            /* Handle mouse clicked. */
            if ((e.getModifiers()
                    & java.awt.event.InputEvent.BUTTON1_MASK) == java.awt.event.InputEvent.BUTTON1_MASK) {
                // Not sure why during debug mode, we cannot enter this block during mouse click?

                final Object object = AjaxAutoCompleteJComboBox.this.getEditor().getItem();

                // The object can be either String or AjaxYahooSearchEngine.ResultType.
                // If user keys in the item, editor's item will be String.
                // If user clicks on the drop down list, editor's item will be
                // AjaxYahooSearchEngine.ResultType.
                if (object instanceof DispType) {
                    DispType lastEnteredResult = (DispType) object;
                    AjaxAutoCompleteJComboBox.this.dispSubject.notify(AjaxAutoCompleteJComboBox.this,
                            lastEnteredResult);
                }

                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.
                        AjaxAutoCompleteJComboBox.this.getEditor().setItem(null);
                        AjaxAutoCompleteJComboBox.this.hidePopup();
                        AjaxAutoCompleteJComboBox.this.removeAllItems();
                    }
                });

                return;
            }
        }
    };
}