Example usage for java.awt.event KeyEvent VK_SPACE

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

Introduction

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

Prototype

int VK_SPACE

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

Click Source Link

Document

Constant for the SPACE virtual key.

Usage

From source file:SimpleGame.java

/**
 * This is where the work is done. This identifies which key has been
 * pressed and acts accordingly: left key cursor rotate left, right cursor
 * key rotate right, spacebar fire./*from ww w  .j  av  a2 s.  co m*/
 * 
 * @criteria Enumeration that represents the trigger conditions.
 */
public void processStimulus(Enumeration criteria) {
    while (criteria.hasMoreElements()) {
        WakeupCriterion theCriterion = (WakeupCriterion) criteria.nextElement();
        if (theCriterion instanceof WakeupOnAWTEvent) {
            AWTEvent[] triggers = ((WakeupOnAWTEvent) theCriterion).getAWTEvent();
            //Check if it's a keyboard event
            if (triggers[0] instanceof KeyEvent) {
                int keyPressed = ((KeyEvent) triggers[0]).getKeyCode();
                if (keyPressed == KeyEvent.VK_LEFT) {
                    //It's a left key so move the turret
                    //and the aim of the gun left unless
                    //we're at our maximum angle
                    if (aim < 8)
                        aim += 1;
                    System.out.println("Left " + aim);
                    aimShotMat.rotY(((aim / 32.0) + 0.5) * Math.PI);
                    aimGunMat.rotZ(((aim / -32.0)) * Math.PI);
                    aimShotXfm.setRotation(aimShotMat);
                    aimGunXfm.setRotation(aimGunMat);
                    aimXfmGrp.setTransform(aimGunXfm);
                    theInterpolator.setAxisOfTranslation(aimShotXfm);
                } else if (keyPressed == KeyEvent.VK_RIGHT) {
                    //It's the right key so do the same but rotate right
                    if (aim > -8)
                        aim -= 1;
                    System.out.println("Right " + aim);
                    aimShotMat.rotY(((aim / 32.0) + 0.5) * Math.PI);
                    aimGunMat.rotZ(((aim / -32.0)) * Math.PI);
                    aimGunXfm.setRotation(aimGunMat);
                    aimShotXfm.setRotation(aimShotMat);
                    aimXfmGrp.setTransform(aimGunXfm);
                    theInterpolator.setAxisOfTranslation(aimShotXfm);
                } else if (keyPressed == KeyEvent.VK_SPACE) {
                    //It's the spacebar so reset the start time
                    //of the ball's animation
                    theGunAlpha.setStartTime(System.currentTimeMillis());
                }
            }
        }
    }
    wakeupOn(theCriterion);
}

From source file:vistas.ModPersonal.java

private void txt_NameMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_NameMKeyTyped
    char car = evt.getKeyChar();
    if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z') && (car != (char) KeyEvent.VK_SPACE)
            && (car != (char) KeyEvent.VK_BACK_SPACE)) {
        JOptionPane.showMessageDialog(this, "Ingrese solo letras");
        evt.consume();/*from   w ww.  ja  v  a2 s. c o  m*/
    }
}

From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java

/**
 * Creates new form MapFrame//from  w  w w. ja v  a2  s . c  o m
 */
DSWorkbenchMainFrame() {
    initComponents();
    setAlwaysOnTop(false);
    if (!GlobalOptions.isMinimal()) {
        setTitle("DS Workbench " + Constants.VERSION + Constants.VERSION_ADDITION);
    } else {
        setTitle("DS Workbench Mini " + Constants.VERSION + Constants.VERSION_ADDITION);
    }

    jExportDialog.pack();
    jAddROIDialog.pack();

    JOutlookBar outlookBar = new JOutlookBar();
    outlookBar.addBar("Navigation", jNavigationPanel);
    outlookBar.addBar("Information", jInformationPanel);
    outlookBar.addBar("Karte", jMapPanel);
    outlookBar.addBar("ROI", jROIPanel);
    outlookBar.setVisibleBar(1);
    jSettingsScrollPane.setViewportView(outlookBar);

    mAbout = new AboutDialog(this, true);
    mAbout.pack();
    chooser.setDialogTitle("Speichern unter...");
    chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {

        @Override
        public boolean accept(File f) {
            return (f != null) && (f.isDirectory() || f.getName().endsWith(".png"));
        }

        @Override
        public String getDescription() {
            return "PNG Image (*.png)";
        }
    });

    chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {

        @Override
        public boolean accept(File f) {
            return (f != null) && (f.isDirectory() || f.getName().endsWith(".jpeg"));
        }

        @Override
        public String getDescription() {
            return "JPEG Image (*.jpeg)";
        }
    });

    //Schedule Backup
    new Timer("BackupTimer", true).schedule(new BackupTask(), 60 * 10000, 60 * 10000);

    //give focus to map panel if mouse enters map
    jMapPanelHolder.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            jMapPanelHolder.requestFocusInWindow();
        }
    });

    getContentPane().setBackground(Constants.DS_BACK);
    pack();
    capabilityInfoPanel1.addActionListener(MapPanel.getSingleton());

    // <editor-fold defaultstate="collapsed" desc=" Add global KeyListener ">
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {

        @Override
        public void eventDispatched(AWTEvent event) {
            if (event.getID() == KeyEvent.KEY_PRESSED) {
                KeyEvent e = (KeyEvent) event;
                if (DSWorkbenchMainFrame.getSingleton().isActive()) {
                    //move shortcuts
                    if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                        scroll(0.0, 2.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                        scroll(0.0, -2.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                        scroll(-2.0, 0.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                        scroll(2.0, 0.0);
                    } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //shot minimap tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_AXE);
                    } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack axe tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_RAM);
                    } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack ram tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SNOB);
                    } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack snob tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SPY);
                    } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack sword tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_LIGHT);
                    } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack light tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_HEAVY);
                    } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack heavy tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SWORD);
                    } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isControlDown() && !e.isAltDown()) {
                        //search frame shortcut
                        DSWorkbenchSearchFrame.getSingleton()
                                .setVisible(!DSWorkbenchSearchFrame.getSingleton().isVisible());
                    }
                }

                //misc shortcuts
                if ((e.getKeyCode() == KeyEvent.VK_0) && e.isAltDown()) {
                    //no tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_DEFAULT);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //measure tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MEASURE);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //mark tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MARK);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //tag tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_TAG);
                } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SUPPORT);
                } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SELECTION);
                } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_RADAR);
                } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_INGAME);
                } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //res ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SEND_RES_INGAME);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //move minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MOVE);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //zoom minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ZOOM);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //shot minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SHOT);
                } else if ((e.getKeyCode() == KeyEvent.VK_T) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //search time shortcut
                    ClockFrame.getSingleton().setVisible(!ClockFrame.getSingleton().isVisible());
                } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    planMapshot();
                } else if (e.getKeyCode() == KeyEvent.VK_F2) {
                    DSWorkbenchAttackFrame.getSingleton()
                            .setVisible(!DSWorkbenchAttackFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F3) {
                    DSWorkbenchMarkerFrame.getSingleton()
                            .setVisible(!DSWorkbenchMarkerFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F4) {
                    DSWorkbenchTroopsFrame.getSingleton()
                            .setVisible(!DSWorkbenchTroopsFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F5) {
                    DSWorkbenchRankFrame.getSingleton()
                            .setVisible(!DSWorkbenchRankFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F6) {
                    DSWorkbenchFormFrame.getSingleton()
                            .setVisible(!DSWorkbenchFormFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F7) {
                    if (ServerSettings.getSingleton().isChurch()) {
                        DSWorkbenchChurchFrame.getSingleton()
                                .setVisible(!DSWorkbenchChurchFrame.getSingleton().isVisible());
                    }
                } else if (e.getKeyCode() == KeyEvent.VK_F8) {
                    DSWorkbenchConquersFrame.getSingleton()
                            .setVisible(!DSWorkbenchConquersFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F9) {
                    DSWorkbenchNotepad.getSingleton()
                            .setVisible(!DSWorkbenchNotepad.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F10) {
                    DSWorkbenchTagFrame.getSingleton()
                            .setVisible(!DSWorkbenchTagFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F11) {
                    DSWorkbenchStatsFrame.getSingleton()
                            .setVisible(!DSWorkbenchStatsFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F12) {
                    DSWorkbenchSettingsDialog.getSingleton().setVisible(true);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 1
                    centerROI(0);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 2
                    centerROI(1);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 3
                    centerROI(2);
                } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 4
                    centerROI(3);
                } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 5
                    centerROI(4);
                } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 6
                    centerROI(5);
                } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 7
                    centerROI(6);
                } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 8
                    centerROI(7);
                } else if ((e.getKeyCode() == KeyEvent.VK_9) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 9
                    centerROI(8);
                } else if ((e.getKeyCode() == KeyEvent.VK_0) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 10
                    centerROI(9);
                } else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
                    jMapPanelHolder.requestFocusInWindow();
                    MapPanel.getSingleton().setSpaceDown(true);
                } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
                    jMapPanelHolder.requestFocusInWindow();
                    MapPanel.getSingleton().setShiftDown(true);
                }
            } else if (event.getID() == KeyEvent.KEY_RELEASED) {
                KeyEvent e = (KeyEvent) event;
                if (e.getKeyCode() == KeyEvent.VK_SPACE) {
                    MapPanel.getSingleton().setSpaceDown(false);
                } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
                    MapPanel.getSingleton().setShiftDown(false);
                }
            }
        }
    }, AWTEvent.KEY_EVENT_MASK);
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Load UI Icons ">
    try {
        jOnlineLabel.setIcon(new ImageIcon("./graphics/icons/online.png"));
        jEnableClipboardWatchButton.setIcon(new ImageIcon("./graphics/icons/watch_clipboard.png"));
        jCenterIngameButton
                .setIcon(new ImageIcon(DSWorkbenchMainFrame.class.getResource("/res/ui/center_ingame.png")));
        jRefreshButton.setIcon(new ImageIcon("./graphics/icons/refresh.png"));
        jCenterCoordinateIngame.setIcon(new ImageIcon("./graphics/icons/center.png"));
    } catch (Exception e) {
        logger.error("Failed to load status icon(s)", e);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Check for desktop support ">
    if (!Desktop.isDesktopSupported()) {
        jCenterIngameButton.setEnabled(false);
        jCenterCoordinateIngame.setEnabled(false);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Restore last map position ">
    try {
        String x = GlobalOptions.getSelectedProfile().getProperty("last.x");
        String y = GlobalOptions.getSelectedProfile().getProperty("last.y");
        centerPosition(Double.parseDouble(x), Double.parseDouble(y));
    } catch (Exception e) {
        centerPosition(ServerSettings.getSingleton().getMapDimension().getCenterX(),
                ServerSettings.getSingleton().getMapDimension().getCenterY());
    }

    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Restore other settings ">
    jShowMapPopup.setSelected(GlobalOptions.getProperties().getBoolean("show.map.popup"));
    jShowMouseOverInfo.setSelected(GlobalOptions.getProperties().getBoolean("show.mouseover.info"));
    jIncludeSupport.setSelected(GlobalOptions.getProperties().getBoolean("include.support"));
    jHighlightTribeVillages.setSelected(GlobalOptions.getProperties().getBoolean("highlight.tribes.villages"));
    jShowRuler.setSelected(GlobalOptions.getProperties().getBoolean("show.ruler"));
    jDisplayChurch.setSelected(GlobalOptions.getProperties().getBoolean("show.church"));
    jDisplayWatchtower.setSelected(GlobalOptions.getProperties().getBoolean("show.watchtower"));
    jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch());
    jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower());
    ServerSettings.getSingleton().addListener(new ServerSettingsListener() {
        @Override
        public void fireServerSettingsChanged() {
            jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch());
            jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower());
        }
    });
    int r = GlobalOptions.getProperties().getInt("radar.size");
    int hour = r / 60;
    jHourField.setText(Integer.toString(hour));
    jMinuteField.setText(Integer.toString(r - hour * 60));
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Skin Setup">
    DefaultComboBoxModel gpModel = new DefaultComboBoxModel(GlobalOptions.getAvailableSkins());
    jGraphicPacks.setModel(gpModel);
    String skin = GlobalOptions.getProperty("default.skin");
    if (gpModel.getIndexOf(skin) != -1) {
        jGraphicPacks.setSelectedItem(skin);
    } else {
        jGraphicPacks.setSelectedItem("default");
    }
    //</editor-fold>

    minZoom = GlobalOptions.getProperties().getDouble("map.zoom.min");
    maxZoom = GlobalOptions.getProperties().getDouble("map.zoom.max");
    dZoomInOutFactor = GlobalOptions.getProperties().getDouble("map.zoom.in.out.factor");

    mNotificationHideThread = new NotificationHideThread();
    mNotificationHideThread.start();
    SystrayHelper.installSystrayIcon();
    //update online state
    onlineStateChanged();
    restoreProperties();
}

From source file:me.solhub.simple.engine.DebugLocationsStructure.java

/**
 * Switches the color of the agent from destination to group or vice versa
 * whenever the space bar is pressed/*from w w w .j a  v  a 2s.  c o  m*/
 */
private void handleColorSwitchingInput() {
    if (_input.isKeyDown(KeyEvent.VK_SPACE) && inputDelayCount > inputDelay) {
        isDestinationColors = !isDestinationColors;
        inputDelayCount = 0;
    }
    if (_input.isKeyDown(KeyEvent.VK_PERIOD)) {
        LIVE_DELAY += 1;
        if (LIVE_DELAY < 0) {
            LIVE_DELAY = 0;
        }
    }
    if (_input.isKeyDown(KeyEvent.VK_COMMA)) {
        LIVE_DELAY -= 1;
        if (LIVE_DELAY < 0) {
            LIVE_DELAY = 0;
        }
    }
    if (_input.isKeyDown(KeyEvent.VK_UP)) {
        _yOffset += 1;
    }
    if (_input.isKeyDown(KeyEvent.VK_DOWN)) {
        _yOffset -= 1;
    }
    if (_input.isKeyDown(KeyEvent.VK_RIGHT)) {
        _xOffset -= 1;
    }
    if (_input.isKeyDown(KeyEvent.VK_LEFT)) {
        _xOffset += 1;
    }
    if (_input.isKeyDown(KeyEvent.VK_ENTER)) {
        while (!_input.isKeyDown(KeyEvent.VK_SHIFT)) {
            //this makes it work, without this line it will not work as desired
            //                System.out.println(_input.isKeyDown( KeyEvent.VK_ENTER ));
            draw();
            handleColorSwitchingInput();
        }
    }
    inputDelayCount++;
}

From source file:statechum.analysis.learning.Visualiser.java

/** Creates key bindings used in all Statechum windows.
  * // ww  w.  java 2 s .com
  * @param frame frame of the window
  * @param windowID the identifier of the window in the config file - used to store/restore window positions
  * @param keyToActionMap map to store key bindings in.
  */
public static void setStateChumKeyBindings(final JFrame frame, final int windowID,
        Map<Integer, Action> keyToActionMap) {
    keyToActionMap.put(KeyEvent.VK_F4,
            new graphAction("saveWindows", "save the current position/size of graph windows") {

                /** Serial number. */
                private static final long serialVersionUID = 4L;

                @Override
                public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
                    globalConfig.saveFrame(frame, windowID);
                    globalConfig.saveConfiguration();
                }
            });

    if (Boolean.valueOf(GlobalConfiguration.getConfiguration()
            .getProperty(GlobalConfiguration.G_PROPERTIES.ESC_TERMINATE))) {
        keyToActionMap.put(KeyEvent.VK_ESCAPE, new graphAction("terminate", "terminates this program") {

            /** Serial number. */
            private static final long serialVersionUID = 5L;

            @Override
            public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
                frame.setVisible(false);
                frame.dispose();
                Visualiser.syncValue.set(true);
                DrawGraphs.end();
                System.exit(1);
                /*
                synchronized (Visualiser.syncObject) {
                Visualiser.syncObject.notify();
                }*/
            }
        });
    }
    keyToActionMap.put(KeyEvent.VK_SPACE, new graphAction("step", "exits the Visualiser.waitForKey() call") {

        /** Serial number. */
        private static final long serialVersionUID = 6L;

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            Visualiser.syncValue.set(false);
            synchronized (Visualiser.syncObject) {
                Visualiser.syncObject.notify();
            }
        }
    });

}

From source file:vistas.GestionPersonal.java

private void txt_NameKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_NameKeyTyped
    char car = evt.getKeyChar();
    if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z') && (car != (char) KeyEvent.VK_SPACE)
            && (car != (char) KeyEvent.VK_BACK_SPACE)) {
        JOptionPane.showMessageDialog(this, "Ingrese solo letras");
        evt.consume();/*from   w ww.  j  a v  a 2s  . c  o m*/
    }
}

From source file:vistas.GestionPersonal.java

private void txt_apellidoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_apellidoKeyTyped
    char car = evt.getKeyChar();
    if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z') && (car != (char) KeyEvent.VK_SPACE)
            && (car != (char) KeyEvent.VK_BACK_SPACE)) {
        JOptionPane.showMessageDialog(this, "Ingrese solo letras");
        evt.consume();//from  w w w.j a  v a 2s .  co  m
    }
}

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

private void vechicleTypesListKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_INSERT) {
        createTypeBtnActionPerformed(null);
    }/*  w  ww  .  j a  va  2 s . co  m*/
    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  a v a  2s.  c  om*/
    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:org.executequery.gui.editor.QueryEditorTextPane.java

/**
 * Overrides <code>processKeyEvent</code> to additional process events.
 *///from w w w .  ja v a 2s.c o  m
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();
}