Example usage for java.awt.event KeyEvent getKeyCode

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

Introduction

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

Prototype

public int getKeyCode() 

Source Link

Document

Returns the integer keyCode associated with the key in this event.

Usage

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

private void tbFilterCodeKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        btnSearchFilterActionPerformed(null);
    }/*from w ww  . j  av  a 2 s. c o  m*/
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        tbFilterCode.setText("");
    }

    adjustButtonsEnabled();
}

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  .  j  a v a  2 s .c  om
    if (e.getKeyCode() == KeyEvent.VK_DELETE) {
        btnRemoveFilterActionPerformed(null);
    }
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
        btnEditFilterActionPerformed(null);
    }
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

private void jCallGraphScaleTextFieldKeyPressed(KeyEvent evt) {
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        jCallGraphScaleTextFieldFocusLost(null);
    }/*w  w  w .j a va2 s .co m*/
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

private void jSearchTextFieldKeyPressed(KeyEvent evt) {
    if ((evt.getKeyCode() == KeyEvent.VK_ENTER)) {
        ValueAxis xAxis = this.jfcMemory.getXYPlot().getDomainAxis();
        // Double max = jfcMemory.getMax(jfcMemory.getXYPlot().getDataset(),
        // xAxis.getRange());

        long columnCount = Data.getColumnCount(
                CommonLib.convertFilesize((String) jFromComboBox.getSelectedItem()),
                CommonLib.convertFilesize((String) jToComboBox.getSelectedItem()),
                CommonLib.convertFilesize((String) jBlockSizeComboBox.getSelectedItem()));
        long address = CommonLib.convertFilesize(jSearchTextField.getText());
        long blockSize = CommonLib.convertFilesize((String) jBlockSizeComboBox.getSelectedItem());
        long blockNo = address / blockSize;
        long x = blockNo % columnCount;
        long y = blockNo / columnCount;
        MyXYBlockRenderer renderer = (MyXYBlockRenderer) jfcMemory.getXYPlot().getRenderer();
        renderer.setRealX((int) x);
        renderer.setRealY((int) y);
        updateHotestTable(address, blockSize);
        jfcMemory.fireChartChanged();/*from www  .  ja v  a2  s  .  c o m*/
        // ((DefaultXYZDataset)
        // jfcMemory.getXYPlot().getDataset()).addSeries(null, null);
        // jMemoryChartPanel.repaint();
    }
}

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

private void tbOeKeyTyped(KeyEvent e) {
    if (e != null) {
        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
            btnOeSearchActionPerformed(null);
        }//from   w  ww.  ja v a  2s .  c o m
        if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
            tbOe.setText("");
        }
    }

    adjustButtonsEnabled();
}

From source file:haven.GameUI.java

public boolean globtype(char key, KeyEvent ev) {
    if (key == ':') {
        entercmd();/*from  w w w .j  a v  a 2s.  co m*/
        return (true);
    } else if (key == ' ') {
        toggleui();
        return (true);
    } else if (key == 3) {
        if (chat.visible && !chat.hasfocus) {
            setfocus(chat);
        } else {
            if (chat.sz.y == 0) {
                chat.resize(chat.savedw, chat.savedh);
                setfocus(chat);
            } else {
                chat.resize(0, 0);
            }
        }
        Utils.setprefb("chatvis", chat.sz.y != 0);
    } else if (key == 16) {
        /*
        if((polity != null) && polity.show(!polity.visible)) {
        polity.raise();
        fitwdg(polity);
        setfocus(polity);
        }
        */
        return (true);
    } else if ((key == 27) && (map != null) && !map.hasfocus) {
        setfocus(map);
        return (true);
    } else if (key != 0) {
        boolean alt = ev.isAltDown();
        boolean ctrl = ev.isControlDown();
        boolean shift = ev.isShiftDown();
        int keycode = ev.getKeyCode();
        if (alt && keycode >= KeyEvent.VK_0 && keycode <= KeyEvent.VK_9) {
            beltwdg.setCurrentBelt(Utils.floormod(keycode - KeyEvent.VK_0 - 1, 10));
            return true;
        } else if (alt && keycode == KeyEvent.VK_S) {
            studywnd.show(!studywnd.visible);
            if (studywnd.visible)
                studywnd.raise();
            return true;
        } else if (alt && keycode == KeyEvent.VK_M) {
            if (mmapwnd != null) {
                mmapwnd.togglefold();
                return true;
            }
        } else if (alt && keycode == KeyEvent.VK_C) {
            craftwnd.show(!craftwnd.visible);
            if (craftwnd.visible)
                craftwnd.raise();
            return true;
        } else if (alt && keycode == KeyEvent.VK_B) {
            buildwnd.toggle();
            if (buildwnd.visible)
                buildwnd.raise();
            return true;
        } else if (alt && keycode == KeyEvent.VK_N) {
            Config.nightvision.set(!Config.nightvision.get());
        } else if (alt && keycode == KeyEvent.VK_G) {
            if (map != null)
                map.gridOverlay.setVisible(!map.gridOverlay.isVisible());
            return true;
        } else if (alt && keycode == KeyEvent.VK_R) {
            if (mmap != null)
                mmap.toggleCustomIcons();
            return true;
        } else if (alt && keycode == KeyEvent.VK_D) {
            if (map != null)
                map.toggleGobRadius();
            return true;
        } else if (alt && keycode == KeyEvent.VK_Q) {
            Config.showQuality.set(!Config.showQuality.get());
            return true;
        } else if (alt && keycode == KeyEvent.VK_K) {
            deckwnd.show(!deckwnd.visible);
            deckwnd.c = new Coord(sz.sub(deckwnd.sz).div(2));
            if (deckwnd.visible)
                deckwnd.raise();
            return true;
        } else if (alt && keycode == KeyEvent.VK_F) {
            if (map != null) {
                map.toggleFriendlyFire();
                msg("Friendly fire prevention is now turned "
                        + (map.isPreventFriendlyFireEnabled() ? "on" : "off"));
            }
            return true;
        } else if (alt && keycode == KeyEvent.VK_I) {
            Config.showGobInfo.set(!Config.showGobInfo.get());
            return true;
        } else if (alt && keycode == KeyEvent.VK_W) {
            Config.screenshotMode = !Config.screenshotMode;
            return true;
        } else if (alt && keycode == KeyEvent.VK_T) {
            Config.disableTileTransitions.set(!Config.disableTileTransitions.get());
            ui.sess.glob.map.rebuild();
            return true;
        } else if (keycode == KeyEvent.VK_Q && ev.getModifiers() == 0) {
            /*
            // get all forageables from config
            List<String> names = new ArrayList<String>();
            for (CustomIconGroup group : ui.sess.glob.icons.config.groups) {
                if ("Forageables".equals(group.name)) {
            for (CustomIconMatch match : group.matches)
                if (match.show)
                    names.add(match.value);
            break;
                }
            }
            tasks.add(new Forager(11 * Config.autopickRadius.get(), 1, names.toArray(new String[names.size()]))); 
            */
            ContextTaskFinder.checkForageables(tasks, ui);
            return true;
        } else if (keycode == KeyEvent.VK_E && ev.getModifiers() == 0) {
            ContextTaskFinder.findHandTask(tasks, ui);
            return true;
        } else if (keycode == KeyEvent.VK_F && ev.getModifiers() == 0) {
            ContextTaskFinder.findBuilding(tasks, ui);
            return true;
        } else if (keycode >= KeyEvent.VK_NUMPAD1 && keycode <= KeyEvent.VK_NUMPAD4) {
            tasks.add(new MileStoneTask(Utils.floormod(keycode - KeyEvent.VK_NUMPAD0 - 1, 10)));
            return true;
        } else if (keycode == KeyEvent.VK_W && ev.getModifiers() == 0) {
            tasks.add(new Drunkard());
            return true;
        } else if (shift && keycode == KeyEvent.VK_I) {
            Config.hideKinInfoForNonPlayers.set(!Config.hideKinInfoForNonPlayers.get());
            return true;
        } else if (ctrl && keycode == KeyEvent.VK_H) {
            Config.hideModeEnabled.set(!Config.hideModeEnabled.get());
            return true;
        } else if (alt && keycode == KeyEvent.VK_P) {
            Config.showGobPaths.set(!Config.showGobPaths.get());
            return true;
        } else if (shift && keycode == KeyEvent.VK_W) {
            if (Config.showQualityMode.get() == 1) {
                Config.showQualityMode.set(2);
            } else {
                Config.showQualityMode.set(1);
            }
            return true;
        } else if (keycode == KeyEvent.VK_TAB && Config.agroclosest.get()) {
            if (map != null)
                map.aggroclosest();
            return true;
        } else if (ctrl && keycode == KeyEvent.VK_F) {
            Config.displayFPS.set(!Config.displayFPS.get());
            return true;
        } else if (keycode == KeyEvent.VK_Z && ev.getModifiers() == 0) {
            tasks.killAllTasks();
            return true;
        } else if (keycode == 192 && ev.getModifiers() == 0) {
            getparent(GameUI.class).menu.wdgmsg("act", "travel", "hearth");
            return true;
        } else if (shift && keycode == KeyEvent.VK_S) {
            HavenPanel.screenshot = true;
            return true;
        }
    }
    return (super.globtype(key, ev));
}

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

private void globalHotkeys() {
    class FiltersPanelGlobalHotkey extends EventQueue {
        protected void dispatchEvent(AWTEvent event) {
            if (event instanceof KeyEvent) {
                KeyEvent keyEvent = (KeyEvent) event;
                if (keyEvent.getKeyCode() == KeyEvent.VK_F1 && keyEvent.getID() == KeyEvent.KEY_PRESSED) {
                } else {
                    super.dispatchEvent(event);
                }//from  www . j av  a 2  s  .c  om
            } else {
                super.dispatchEvent(event);
            }
        }
    }

    EventQueue ev = Toolkit.getDefaultToolkit().getSystemEventQueue();
    ev.push(new FiltersPanelGlobalHotkey());
}

From source file:fs.MainWindow.java

public MainWindow() {
    initComponents();/*from w w w.  j a  v  a2  s. c o  m*/
    //inicializacao do modelo numerido usado na definicao dos parametros.
    jS_QuantizationValue.setModel(new SpinnerNumberModel(2, 1, Integer.MAX_VALUE, 1));
    jS_MaxResultListSE.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1));
    jS_MaxSetSizeSE.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1));
    jS_MaxSetSizeCV.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1));
    jS_NrExecutionsCV.setModel(new SpinnerNumberModel(10, 1, Integer.MAX_VALUE, 1));
    jS_ThresholdEntropy.setModel(new SpinnerNumberModel(0.3, 0, 1, 0.05));
    jS_QEntropyCV.setModel(new SpinnerNumberModel(1d, 0.1d, Double.MAX_VALUE, 0.1d));
    jS_AlphaCV.setModel(new SpinnerNumberModel(1d, 0d, Double.MAX_VALUE, 0.1d));
    jS_QEntropySE.setModel(new SpinnerNumberModel(1d, 0.1d, Double.MAX_VALUE, 0.1d));
    jS_AlphaSE.setModel(new SpinnerNumberModel(1d, 0d, Double.MAX_VALUE, 0.1d));

    //captura teclas pressionadas, se for F1 aciona o JFrame Help.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {

        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_F1 && e.getID() == KeyEvent.KEY_PRESSED) {
                if (help != null) {
                    help.setVisible(false);
                    help.dispose();
                }
                if (jTabbedPane1.getSelectedIndex() == 0) {
                    help = new HelpInput();
                } else if (jTabbedPane1.getSelectedIndex() == 1) {
                    help = new HelpQuantization();
                } else if (jTabbedPane1.getSelectedIndex() == 2) {
                    help = new HelpFS();
                } else if (jTabbedPane1.getSelectedIndex() == 3) {
                    help = new HelpCV();
                }
                help.setVisible(true);
                return true;
            }
            return false;
        }
    });
}

From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java

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

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        search();//  w w w.  java  2 s.  c o  m
    }

}

From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java

private void jTreeResultsKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTreeResultsKeyReleased
    if (KeyEvent.VK_DELETE == evt.getKeyCode() && clientCore.isAdmin()) {
        ArrayList<String> files = getSelectedLocalFiles();

        if (files != null && !files.isEmpty()) {
            try {
                Object[] opt = { "Remove and Delete", "Remove", "Cancel" };
                String message = "Are you sure you want to remove these files from Index Engine?";

                int op = JOptionPane.showOptionDialog(this, message, "Remove Files",
                        JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, opt, opt[2]);

                if (op == 0) {
                    AdminRefs.getInstance().getIndexOptions().removeFilesFromIndexer(files, true);
                }/*from  w ww.j  av  a2s .c  o  m*/
                if (op == 1) {
                    AdminRefs.getInstance().getIndexOptions().removeFilesFromIndexer(files, false);
                }
            } catch (RemoteException ex) {
                Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}