Example usage for java.awt.event KeyEvent VK_INSERT

List of usage examples for java.awt.event KeyEvent VK_INSERT

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_INSERT.

Prototype

int VK_INSERT

To view the source code for java.awt.event KeyEvent VK_INSERT.

Click Source Link

Document

Constant for the INSERT key.

Usage

From source file:ru.goodfil.catalog.ui.forms.OePanel.java

private void lstBrandsKeyPressed(KeyEvent e) {
    if (e != null) {
        if (e.getKeyCode() == KeyEvent.VK_INSERT) {
            btnCreateBrandActionPerformed(null);
        }/*w  w  w  .j av a2  s .  co  m*/
        if (e.getKeyCode() == KeyEvent.VK_DELETE) {
            btnRemoveBrandActionPerformed(null);
        }
        if (e.getKeyCode() == KeyEvent.VK_SPACE) {
            btnEditBrandActionPerformed(null);
        }
    }
}

From source file:ru.goodfil.catalog.ui.forms.OePanel.java

private void lstOesKeyPressed(KeyEvent e) {
    if (e != null) {
        if (e.getKeyCode() == KeyEvent.VK_INSERT) {
            btnCreateOeActionPerformed(null);
        }/*from  w  ww. j a  v  a  2s.  co  m*/
        if (e.getKeyCode() == KeyEvent.VK_DELETE) {
            btnRemoveOeActionPerformed(null);
        }
        if (e.getKeyCode() == KeyEvent.VK_SPACE) {
            btnEditOeActionPerformed(null);
        }
        if ((e.getKeyCode() == KeyEvent.VK_X) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
            List<Oe> selectedOes = oes.getSelectedItems();
            putObjectToMyClipboard(selectedOes);
            this.setOperation(OPERATION_CUT);
        }
        if ((e.getKeyCode() == KeyEvent.VK_C) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
            List<Oe> selectedOes = oes.getSelectedItems();
            putObjectToMyClipboard(selectedOes);
            this.setOperation(OPERATION_COPY);
        }
        if ((e.getKeyCode() == KeyEvent.VK_V) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
            if (popupMenu1.getInvoker() == lstOes) {
                List<Oe> selectedOes = new ArrayList();
                selectedOes.addAll(getFromClipboardByType(Oe.class));
                if (selectedOes.size() > 0) {
                    Long brand = brands.getSelectedItemId();
                    Assert.notNull(brand);
                    if (getOperation() == OPERATION_COPY) {
                        analogsService.doCopyOe(selectedOes, brand);
                    }
                    if (getOperation() == OPERATION_CUT) {
                        analogsService.doCutOe(selectedOes, brand);
                    }
                    reReadOes(brand);
                }
            }
        }
    }
}

From source file:xtrememp.PlaylistManager.java

private void initComponents() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);/*from w ww. ja v  a2  s  . c o  m*/
    openPlaylistButton = new JButton(Utilities.DOCUMENT_OPEN_ICON);
    openPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.OpenPlaylist"));
    openPlaylistButton.addActionListener(this);
    toolBar.add(openPlaylistButton);
    savePlaylistButton = new JButton(Utilities.DOCUMENT_SAVE_ICON);
    savePlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.SavePlaylist"));
    savePlaylistButton.addActionListener(this);
    toolBar.add(savePlaylistButton);
    toolBar.addSeparator();
    addToPlaylistButton = new JButton(Utilities.LIST_ADD_ICON);
    addToPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.AddToPlaylist"));
    addToPlaylistButton.addActionListener(this);
    toolBar.add(addToPlaylistButton);
    remFromPlaylistButton = new JButton(Utilities.LIST_REMOVE_ICON);
    remFromPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.RemoveFromPlaylist"));
    remFromPlaylistButton.addActionListener(this);
    remFromPlaylistButton.setEnabled(false);
    toolBar.add(remFromPlaylistButton);
    clearPlaylistButton = new JButton(Utilities.EDIT_CLEAR_ICON);
    clearPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.ClearPlaylist"));
    clearPlaylistButton.addActionListener(this);
    clearPlaylistButton.setEnabled(false);
    toolBar.add(clearPlaylistButton);
    toolBar.addSeparator();
    moveUpButton = new JButton(Utilities.GO_UP_ICON);
    moveUpButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveUp"));
    moveUpButton.addActionListener(this);
    moveUpButton.setEnabled(false);
    toolBar.add(moveUpButton);
    moveDownButton = new JButton(Utilities.GO_DOWN_ICON);
    moveDownButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveDown"));
    moveDownButton.addActionListener(this);
    moveDownButton.setEnabled(false);
    toolBar.add(moveDownButton);
    toolBar.addSeparator();
    mediaInfoButton = new JButton(Utilities.MEDIA_INFO_ICON);
    mediaInfoButton.setToolTipText(tr("MainFrame.PlaylistManager.MediaInfo"));
    mediaInfoButton.addActionListener(this);
    mediaInfoButton.setEnabled(false);
    toolBar.add(mediaInfoButton);
    toolBar.add(Box.createHorizontalGlue());
    searchTextField = new SearchTextField(15);
    searchTextField.setMaximumSize(new Dimension(120, searchTextField.getPreferredSize().height));
    searchTextField.getTextField().getDocument().addDocumentListener(new SearchFilterListener());
    toolBar.add(searchTextField);
    toolBar.add(Box.createHorizontalStrut(6));
    this.add(toolBar, BorderLayout.NORTH);

    playlistTable = new JTable(playlistTableModel, playlistTableColumnModel);
    playlistTable.setDefaultRenderer(String.class, new PlaylistCellRenderer());
    playlistTable.setActionMap(null);

    playlistTable.getTableHeader().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            if (SwingUtilities.isRightMouseButton(ev)
                    || (MouseInfo.getNumberOfButtons() == 1 && ev.isControlDown())) {
                playlistTableColumnModel.getPopupMenu().show(playlistTable.getTableHeader(), ev.getX(),
                        ev.getY());
                return;
            }

            int clickedColumn = playlistTableColumnModel.getColumnIndexAtX(ev.getX());
            PlaylistTableColumn playlistColumn = playlistTableColumnModel.getColumn(clickedColumn);
            playlistTableColumnModel.resetAll(playlistColumn.getModelIndex());
            playlistColumn.setSortOrderUp(!playlistColumn.isSortOrderUp());
            playlistTableModel.sort(playlistColumn.getComparator());

            colorizeRow();
        }
    });
    playlistTable.setFillsViewportHeight(true);
    playlistTable.setShowGrid(false);
    playlistTable.setRowSelectionAllowed(true);
    playlistTable.setColumnSelectionAllowed(false);
    playlistTable.setDragEnabled(false);
    playlistTable.setFont(playlistTable.getFont().deriveFont(Font.BOLD));
    playlistTable.setIntercellSpacing(new Dimension(0, 0));
    playlistTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    playlistTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            int selectedRow = playlistTable.rowAtPoint(ev.getPoint());
            if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) {
                if (selectedRow != -1) {
                    playlist.setCursorPosition(selectedRow);
                    controlListener.acOpenAndPlay();
                }
            }
        }
    });
    playlistTable.getSelectionModel().addListSelectionListener(this);
    playlistTable.getColumnModel().getSelectionModel().addListSelectionListener(this);
    playlistTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            // View Media Info
            if (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK) {
                viewMediaInfo();
            } // Select all
            else if (e.getKeyCode() == KeyEvent.VK_A && e.getModifiers() == KeyEvent.CTRL_MASK) {
                playlistTable.selectAll();
            } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                // Move selected track(s) up
                if (e.getModifiers() == KeyEvent.ALT_MASK) {
                    moveUp();
                } // Select previous track
                else {
                    if (playlistTable.getSelectedRow() > 0) {
                        int previousRowIndex = playlistTable.getSelectedRow() - 1;
                        playlistTable.clearSelection();
                        playlistTable.addRowSelectionInterval(previousRowIndex, previousRowIndex);
                        makeRowVisible(previousRowIndex);
                    }
                }
            } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                // Move selected track(s) down
                if (e.getModifiers() == KeyEvent.ALT_MASK) {
                    moveDown();
                } // Select next track
                else {
                    if (playlistTable.getSelectedRow() < playlistTable.getRowCount() - 1) {
                        int nextRowIndex = playlistTable.getSelectedRow() + 1;
                        playlistTable.clearSelection();
                        playlistTable.addRowSelectionInterval(nextRowIndex, nextRowIndex);
                        makeRowVisible(nextRowIndex);
                    }
                }
            } // Play selected track
            else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                int selectedRow = playlistTable.getSelectedRow();
                if (selectedRow != -1) {
                    playlist.setCursorPosition(selectedRow);
                    controlListener.acOpenAndPlay();
                }
            } // Add new tracks
            else if (e.getKeyCode() == KeyEvent.VK_INSERT) {
                addFilesDialog(false);
            } // Delete selected tracks
            else if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                remove();
            }
        }
    });
    XtremeMP.getInstance().getMainFrame().setDropTarget(new DropTarget(playlistTable, this));
    JScrollPane ptScrollPane = new JScrollPane(playlistTable);
    ptScrollPane.setActionMap(null);
    this.add(ptScrollPane, BorderLayout.CENTER);
}