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:GUI.MainWindow.java

private void VulnReferencesListKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_VulnReferencesListKeyPressed

    int pressed = evt.getKeyCode();
    if (pressed == KeyEvent.VK_DELETE) {

        deleteReferences(VulnTree, VulnReferencesList);

    } else if (pressed == KeyEvent.VK_INSERT) {
        addReference(VulnTree, VulnReferencesList, null);
    }/*  ww w.j ava 2  s  .  c  o m*/

}

From source file:GUI.MainWindow.java

private void jScrollPane4KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jScrollPane4KeyPressed

    if (evt.getKeyCode() == KeyEvent.VK_INSERT) {
        addAffectedHost();/*from   w  w w.  j  a  va2  s. c o m*/
    }

}

From source file:com.willwinder.universalgcodesender.MainWindow.java

private void initProgram() {
    Localization.initialize(this.settings.getLanguage());
    try {/*from  w  w w .jav  a 2 s  .  com*/
        backend.applySettings(settings);
    } catch (Exception e) {
        displayErrorDialog(e.getMessage());
    }

    this.setLocalLabels();
    this.loadPortSelector();
    this.checkScrollWindow();
    this.loadFirmwareSelector();
    this.setTitle(
            Localization.getString("title") + " (" + Localization.getString("version") + " " + VERSION + ")");

    // Command History
    this.manualCommandHistory = new ArrayList<>();

    // Add keyboard listener for manual controls.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            // Check context.
            if (((arrowMovementEnabled.isSelected()) && e.getID() == KeyEvent.KEY_PRESSED)
                    && xPlusButton.isEnabled()) {
                switch (e.getKeyCode()) {
                case KeyEvent.VK_RIGHT:
                case KeyEvent.VK_KP_RIGHT:
                case KeyEvent.VK_NUMPAD6:
                    xPlusButtonActionPerformed(null);
                    e.consume();
                    return true;
                case KeyEvent.VK_LEFT:
                case KeyEvent.VK_KP_LEFT:
                case KeyEvent.VK_NUMPAD4:
                    xMinusButtonActionPerformed(null);
                    e.consume();
                    return true;
                case KeyEvent.VK_UP:
                case KeyEvent.VK_KP_UP:
                case KeyEvent.VK_NUMPAD8:
                    yPlusButtonActionPerformed(null);
                    e.consume();
                    return true;
                case KeyEvent.VK_DOWN:
                case KeyEvent.VK_KP_DOWN:
                case KeyEvent.VK_NUMPAD2:
                    yMinusButtonActionPerformed(null);
                    e.consume();
                    return true;
                case KeyEvent.VK_PAGE_UP:
                case KeyEvent.VK_NUMPAD9:
                    zPlusButtonActionPerformed(null);
                    e.consume();
                    return true;
                case KeyEvent.VK_PAGE_DOWN:
                case KeyEvent.VK_NUMPAD3:
                    zMinusButtonActionPerformed(null);
                    e.consume();
                    return true;
                case KeyEvent.VK_ADD:
                    increaseStepActionPerformed(null);
                    e.consume();
                    return true;
                case KeyEvent.VK_SUBTRACT:
                    decreaseStepActionPerformed(null);
                    e.consume();
                    return true;
                case KeyEvent.VK_DIVIDE:
                    divideStepActionPerformed(null);
                    e.consume();
                    return true;
                case KeyEvent.VK_MULTIPLY:
                    multiplyStepActionPerformed(null);
                    e.consume();
                    return true;
                case KeyEvent.VK_INSERT:
                case KeyEvent.VK_NUMPAD0:
                    resetCoordinatesButtonActionPerformed(null);
                    e.consume();
                    return true;
                default:
                    break;
                }
            }

            return false;
        }
    });
}

From source file:org.executequery.gui.editor.QueryEditorTextPane.java

/**
 * Overrides <code>processKeyEvent</code> to additional process events.
 *///from ww  w.j av a2s. c om
protected void processKeyEvent(KeyEvent e) {

    if (e.getID() == KeyEvent.KEY_PRESSED) {

        int keyCode = e.getKeyCode();

        // add the processing for SHIFT-TAB
        if (e.isShiftDown() && keyCode == KeyEvent.VK_TAB) {

            //                int currentPosition = getCurrentPosition();
            int selectionStart = getSelectionStart();
            int selectionEnd = getSelectionEnd();

            if (selectionStart == selectionEnd) {

                int start = getCurrentRowStart();
                int end = getCurrentRowEnd();

                shiftTextLeft(start, end);

                /*
                int newPosition = currentPosition - QueryEditorSettings.getTabSize();
                int currentRowPosition = getCurrentRowStart();
                        
                if (!isAtStartOfRow()) {
                        
                if (newPosition < 0) {
                        
                    setCaretPosition(0);
                        
                } else if (newPosition < currentRowPosition) {
                        
                    setCaretPosition(currentRowPosition);
                        
                } else {
                        
                    setCaretPosition(newPosition);
                }
                        
                }
                */

            } else {

                document.shiftTabEvent(selectionStart, selectionEnd);
            }

        } else if (keyCode == KeyEvent.VK_INSERT && e.getModifiers() == 0) {

            // toggle insert mode on the document

            int insertMode = document.getInsertMode();
            if (insertMode == SqlMessages.INSERT_MODE) {

                document.setInsertMode(SqlMessages.OVERWRITE_MODE);
                editorPanel.getStatusBar().setInsertionMode("OVR");

            } else {

                document.setInsertMode(SqlMessages.INSERT_MODE);
                editorPanel.getStatusBar().setInsertionMode("INS");
            }

            ((EditorCaret) getCaret()).modeChanged();

        } else if (keyCode == KeyEvent.VK_SPACE) {

            checkForShortcutText();
        }

    }

    super.processKeyEvent(e);
    updateLineBorder();
}

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

/**
 * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum
 * @param keycode int, a java keycode/* ww  w.  j  a  v a2s . c  om*/
 * @return Keys enum for (primarily) non-printable (control) characters, or null.
 */
public static Keys convertToKeys(int keycode) {
    Keys key = null;
    switch (keycode) {
    case java.awt.event.KeyEvent.VK_ADD:
        key = Keys.ADD;
        break;
    case java.awt.event.KeyEvent.VK_ALT:
        key = Keys.ALT;
        break;
    case java.awt.event.KeyEvent.VK_KP_DOWN:
        key = Keys.ARROW_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_KP_LEFT:
        key = Keys.ARROW_LEFT;
        break;
    case java.awt.event.KeyEvent.VK_KP_RIGHT:
        key = Keys.ARROW_RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_KP_UP:
        key = Keys.ARROW_UP;
        break;
    case java.awt.event.KeyEvent.VK_BACK_SPACE:
        key = Keys.BACK_SPACE;
        break;
    case java.awt.event.KeyEvent.VK_CANCEL:
        key = Keys.CANCEL;
        break;
    case java.awt.event.KeyEvent.VK_CLEAR:
        key = Keys.CLEAR;
        break;
    case java.awt.event.KeyEvent.VK_WINDOWS:
        key = Keys.COMMAND;
        break;
    case java.awt.event.KeyEvent.VK_CONTROL:
        key = Keys.CONTROL;
        break;
    case java.awt.event.KeyEvent.VK_DECIMAL:
        key = Keys.DECIMAL;
        break;
    case java.awt.event.KeyEvent.VK_DELETE:
        key = Keys.DELETE;
        break;
    case java.awt.event.KeyEvent.VK_DIVIDE:
        key = Keys.DIVIDE;
        break;
    case java.awt.event.KeyEvent.VK_DOWN:
        key = Keys.DOWN;
        break;
    case java.awt.event.KeyEvent.VK_END:
        key = Keys.END;
        break;
    case java.awt.event.KeyEvent.VK_ENTER:
        key = Keys.ENTER;
        break;
    case java.awt.event.KeyEvent.VK_EQUALS:
        key = Keys.EQUALS;
        break;
    case java.awt.event.KeyEvent.VK_ESCAPE:
        key = Keys.ESCAPE;
        break;
    case java.awt.event.KeyEvent.VK_F1:
        key = Keys.F1;
        break;
    case java.awt.event.KeyEvent.VK_F2:
        key = Keys.F2;
        break;
    case java.awt.event.KeyEvent.VK_F3:
        key = Keys.F3;
        break;
    case java.awt.event.KeyEvent.VK_F4:
        key = Keys.F4;
        break;
    case java.awt.event.KeyEvent.VK_F5:
        key = Keys.F5;
        break;
    case java.awt.event.KeyEvent.VK_F6:
        key = Keys.F6;
        break;
    case java.awt.event.KeyEvent.VK_F7:
        key = Keys.F7;
        break;
    case java.awt.event.KeyEvent.VK_F8:
        key = Keys.F8;
        break;
    case java.awt.event.KeyEvent.VK_F9:
        key = Keys.F9;
        break;
    case java.awt.event.KeyEvent.VK_F10:
        key = Keys.F10;
        break;
    case java.awt.event.KeyEvent.VK_F11:
        key = Keys.F11;
        break;
    case java.awt.event.KeyEvent.VK_F12:
        key = Keys.F12;
        break;
    case java.awt.event.KeyEvent.VK_HELP:
        key = Keys.HELP;
        break;
    case java.awt.event.KeyEvent.VK_HOME:
        key = Keys.HOME;
        break;
    case java.awt.event.KeyEvent.VK_INSERT:
        key = Keys.INSERT;
        break;
    case java.awt.event.KeyEvent.VK_LEFT:
        key = Keys.LEFT;
        break;
    case java.awt.event.KeyEvent.VK_META:
        key = Keys.META;
        break;
    case java.awt.event.KeyEvent.VK_MULTIPLY:
        key = Keys.MULTIPLY;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD0:
        key = Keys.NUMPAD0;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD1:
        key = Keys.NUMPAD1;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD2:
        key = Keys.NUMPAD2;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD3:
        key = Keys.NUMPAD3;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD4:
        key = Keys.NUMPAD4;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD5:
        key = Keys.NUMPAD5;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD6:
        key = Keys.NUMPAD6;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD7:
        key = Keys.NUMPAD7;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD8:
        key = Keys.NUMPAD8;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD9:
        key = Keys.NUMPAD9;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_DOWN:
        key = Keys.PAGE_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_UP:
        key = Keys.PAGE_UP;
        break;
    case java.awt.event.KeyEvent.VK_PAUSE:
        key = Keys.PAUSE;
        break;
    case java.awt.event.KeyEvent.VK_RIGHT:
        key = Keys.RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_SEMICOLON:
        key = Keys.SEMICOLON;
        break;
    case java.awt.event.KeyEvent.VK_SEPARATOR:
        key = Keys.SEPARATOR;
        break;
    case java.awt.event.KeyEvent.VK_SHIFT:
        key = Keys.SHIFT;
        break;
    case java.awt.event.KeyEvent.VK_SPACE:
        key = Keys.SPACE;
        break;
    case java.awt.event.KeyEvent.VK_SUBTRACT:
        key = Keys.SUBTRACT;
        break;
    case java.awt.event.KeyEvent.VK_TAB:
        key = Keys.TAB;
        break;
    case java.awt.event.KeyEvent.VK_UP:
        key = Keys.UP;
        break;
    }
    return key;
}

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

private void vechicleTypesListKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_INSERT) {
        createTypeBtnActionPerformed(null);
    }// ww  w.ja  va 2  s  .c  om
    if (e.getKeyCode() == KeyEvent.VK_DELETE) {
        removeTypeBtnActionPerformed(null);
    }
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
        editTypeBtnActionPerformed(null);
    }
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        vechicleTypesListValueChanged(null);
    }
}

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

private void manufactorsListKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_INSERT) {
        createManufactorBtnActionPerformed(null);
    }/*  w w  w  .j  ava  2  s  . co  m*/
    if (e.getKeyCode() == KeyEvent.VK_DELETE) {
        removeManufactorBtnActionPerformed(null);
    }
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
        editManufactorBtnActionPerformed(null);
    }
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        manufactorsListValueChanged(null);
    }
    if ((e.getKeyCode() == KeyEvent.VK_X) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        putObjectToMyClipboard(getSelectedManufactors());
        this.setOperation(OPERATION_CUT);
    }
    if ((e.getKeyCode() == KeyEvent.VK_C) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        putObjectToMyClipboard(getSelectedManufactors());
        this.setOperation(OPERATION_COPY);
    }
    if ((e.getKeyCode() == KeyEvent.VK_V) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        List<Manufactor> manufactors = new ArrayList<Manufactor>();
        manufactors.addAll(getFromClipboardByType(Manufactor.class));
        if (manufactors.size() > 0) {
            Long vechicleTypeIdNew = getSelectedVechicleTypeId();
            Assert.notNull(vechicleTypeIdNew);
            if (getOperation() == OPERATION_COPY) {
                carsService.doCopyManufactors(manufactors, vechicleTypeIdNew);
            }
            if (getOperation() == OPERATION_CUT) {
                carsService.doCutManufactors(manufactors, vechicleTypeIdNew);
            }
            reReadManufactors(vechicleTypeIdNew);
        }
    }
}

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

private void seriesListKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_INSERT) {
        createSeriaBtnActionPerformed(null);
    }/*  ww w  .  j a  v a 2 s.c  o m*/
    if (e.getKeyCode() == KeyEvent.VK_DELETE) {
        removeSeriaBtnActionPerformed(null);
    }
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
        editSeriaBtnActionPerformed(null);
    }
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        seriesListValueChanged(null);
    }
    if ((e.getKeyCode() == KeyEvent.VK_X) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        putObjectToMyClipboard(getSelectedSeries());
        this.setOperation(OPERATION_CUT);
    }
    if ((e.getKeyCode() == KeyEvent.VK_C) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        putObjectToMyClipboard(getSelectedSeries());
        this.setOperation(OPERATION_COPY);
    }
    if ((e.getKeyCode() == KeyEvent.VK_V) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        List<Seria> series = new ArrayList<Seria>();
        series.addAll(getFromClipboardByType(Seria.class));
        if (series.size() > 0) {
            Long manufactorIdNew = getSelectedManufatorId();
            Assert.notNull(manufactorIdNew);
            if (getOperation() == OPERATION_COPY) {
                carsService.doCopySeries(series, manufactorIdNew);
            }
            if (getOperation() == OPERATION_CUT) {
                carsService.doCutSeries(series, manufactorIdNew);
            }
            reReadSeries(manufactorIdNew);
        }
    }
}

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

private void motorsTableKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_INSERT) {
        createMotorBtnActionPerformed(null);
    }/*from  w  ww. j  a  v a  2s  .  c om*/
    if (e.getKeyCode() == KeyEvent.VK_DELETE) {
        removeMotorBtnActionPerformed(null);
    }
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
        editMotorBtnActionPerformed(null);
    }
    if ((e.getKeyCode() == KeyEvent.VK_X) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        putObjectToMyClipboard(getSelectedMotors());
        this.setOperation(OPERATION_CUT);
    }
    if ((e.getKeyCode() == KeyEvent.VK_C) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        putObjectToMyClipboard(getSelectedMotors());
        this.setOperation(OPERATION_COPY);
    }
    if ((e.getKeyCode() == KeyEvent.VK_V) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        List<Motor> motors = new ArrayList<Motor>();
        motors.addAll(getFromClipboardByType(Motor.class));
        if (motors.size() > 0) {
            Long seriaIdNew = getSelectedSeriaId();
            Assert.notNull(seriaIdNew);
            if (getOperation() == OPERATION_COPY) {
                carsService.doCopyMotors(motors, seriaIdNew);
            }
            if (getOperation() == OPERATION_CUT) {
                carsService.doCutMotors(motors, seriaIdNew);
            }
            reReadMotors(seriaIdNew);
        }
    }
}

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

private void tblFiltersKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_INSERT) {
        btnCreateFilterActionPerformed(null);
    }//w ww  . jav a 2s  .com
    if (e.getKeyCode() == KeyEvent.VK_DELETE) {
        btnRemoveFilterActionPerformed(null);
    }
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
        btnEditFilterActionPerformed(null);
    }
}