Example usage for java.awt.event KeyEvent VK_UP

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

Introduction

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

Prototype

int VK_UP

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

Click Source Link

Document

Constant for the non-numpad up arrow key.

Usage

From source file:org.squidy.nodes.Wiimote.java

/**
 * Adds a <code>CoreButtonListener</code> to the parameter mote.
 * // ww  w  .  jav  a  2s .c  o  m
 * @param mote
 *            The mote that gets the core button listener.
 */
private CoreButtonListener createCoreButtonListener() {
    return new CoreButtonListener() {

        /*
         * (non-Javadoc)
         * 
         * @see motej.event.CoreButtonListener#buttonPressed(motej.event.CoreButtonEvent)
         */
        public void buttonPressed(CoreButtonEvent evt) {
            // Propagate buttons as button events.
            publish(new DataButton(Wiimote.class, DataButton.BUTTON_1, evt.isButtonAPressed()));
            // TODO Roman: Change button back to BUTTON_3.
            publish(new DataButton(Wiimote.class, DataButton.BUTTON_10, evt.isButtonBPressed()));

            publish(new DataButton(Wiimote.class, DataButton.BUTTON_A, evt.isButtonAPressed()));
            publish(new DataButton(Wiimote.class, DataButton.BUTTON_B, evt.isButtonBPressed()));

            // Home button pressed results in a VK_H key event.
            publish(new DataKey(Wiimote.class, KeyEvent.VK_H, evt.isButtonHomePressed()));

            // Propagate pad keys. -> UP, RIGHT, DOWN, LEFT result in VK_UP,
            // VK_RIGHT, VK_DOWN, VK_LEFT.
            publish(new DataKey(Wiimote.class, KeyEvent.VK_UP, evt.isDPadUpPressed()));
            publish(new DataKey(Wiimote.class, KeyEvent.VK_RIGHT, evt.isDPadRightPressed()));
            publish(new DataKey(Wiimote.class, KeyEvent.VK_DOWN, evt.isDPadDownPressed()));
            publish(new DataKey(Wiimote.class, KeyEvent.VK_LEFT, evt.isDPadLeftPressed()));

            // Button (-) and (+) pressed -> result in VK_MINUS and VK_PLUS
            // key event.
            publish(new DataKey(Wiimote.class, KeyEvent.VK_MINUS, evt.isButtonMinusPressed()));
            publish(new DataKey(Wiimote.class, KeyEvent.VK_PLUS, evt.isButtonPlusPressed()));
            publish(new DataButton(Wiimote.class, DataButton.BUTTON_PLUS, evt.isButtonPlusPressed()));

            // Button (1) and (2) pressed -> result in VK_1 and VK_2 key
            // event.
            publish(new DataKey(Wiimote.class, KeyEvent.VK_1, evt.isButtonOnePressed()));
            publish(new DataKey(Wiimote.class, KeyEvent.VK_2, evt.isButtonTwoPressed()));
        }
    };
}

From source file:ucar.unidata.idv.control.chart.ChartHolder.java

/**
 * Handle event/*from w  w w  .  j  av a2 s  .c  om*/
 *
 * @param e The event
 */
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
        panPlot(true);
    } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
        panPlot(false);
    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
        upDownPlot(true);
    } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
        upDownPlot(false);
    } else if ((e.getKeyCode() == KeyEvent.VK_R) && e.isControlDown()) {
        chartPanel.restoreAutoBounds();
    } else {
        //            super.keyPressed(e);
    }
}

From source file:com.qspin.qtaste.ui.xmleditor.TestRequirementEditor.java

private void genUI() {
    getActionMap().put("Save", new SaveAction());
    getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK), "Save");
    m_TestRequirementTable = new JTable() {

        @Override/*from   w ww.j  a v  a2s  .  c om*/
        public String getToolTipText(MouseEvent e) {
            Point p = e.getPoint();
            int rowIndex = rowAtPoint(p);
            int colIndex = columnAtPoint(p);
            if (colIndex < 0) {
                return null;
            }
            return convertObjectToToolTip(getValueAt(rowIndex, colIndex));
        }

        // overwrite cell content when typing on a selected cell
        @Override
        public Component prepareEditor(TableCellEditor editor, int row, int column) {
            Component c = super.prepareEditor(editor, row, column);

            if (c instanceof JTextComponent) {
                ((JTextField) c).selectAll();
            }

            return c;
        }

        // select entire rows when selecting first column (row id)
        @Override
        public void columnSelectionChanged(ListSelectionEvent e) {
            if (e.getFirstIndex() == 0 && e.getValueIsAdjusting()) {
                setColumnSelectionInterval(1, getColumnCount() - 1);
            } else {
                super.columnSelectionChanged(e);
            }
        }
    };
    m_TestRequirementTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    m_TestRequirementModel = new TestRequirementTableModel();

    m_TestRequirementTable.setModel(m_TestRequirementModel);

    m_TableColumnModelListener = new MyTableColumnModelListener();
    m_TestRequirementTable.setSurrendersFocusOnKeystroke(true);
    m_TestRequirementTable.setColumnSelectionAllowed(true);
    m_TestRequirementTable.addMouseListener(new TableMouseListener(m_TestRequirementTable));
    m_TestRequirementTable.getTableHeader().addMouseListener(new TableMouseListener(m_TestRequirementTable));
    m_TestRequirementTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    m_TestRequirementTable.getActionMap().put("Save", new SaveAction());
    m_TestRequirementTable.setDefaultEditor(String.class, new TestDataTableCellEditor());
    m_TestRequirementTable.setDefaultEditor(Integer.class, new TestDataTableCellEditor());
    m_TestRequirementTable.getTableHeader().getInputMap()
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK), "Save");
    m_TestRequirementTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK),
            "Save");
    m_TestRequirementTable.setRowHeight(ROW_HEIGHT);

    m_TestRequirementTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            //
            if (e.getKeyCode() == KeyEvent.VK_UP) {
                // check if previous line is empty
            }
            if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                // if current row is the last one
                if (m_TestRequirementTable.getSelectedRow() == m_TestRequirementTable.getRowCount() - 1) {
                    addNewRow();
                }
            }
            if ((e.getKeyCode() == KeyEvent.VK_S) && (e.isControlDown())) {
                save();
            }
            if ((e.getKeyCode() == KeyEvent.VK_C) && (e.isControlDown())) {
                copySelectionToClipboard();
            }
            if ((e.getKeyCode() == KeyEvent.VK_V) && (e.isControlDown())) {
                if (m_TestRequirementTable.getSelectedColumn() != 0) {
                    pasteSelectionFromClipboard();
                }
            }
        }
    });

    tableListener = new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            // build the test data
            if (e.getType() == TableModelEvent.UPDATE) {
                if (e.getFirstRow() >= 0) {
                    setModified(true);
                }
            }
        }
    };
    m_TestRequirementModel.addTableModelListener(tableListener);

    JScrollPane sp = new JScrollPane(m_TestRequirementTable);
    sp.addMouseListener(new TableMouseListener(null));
    add(sp);
}

From source file:org.freeplane.view.swing.features.time.mindmapmode.nodelist.NodeList.java

public NodeList(final boolean modal, final boolean showAllNodes, final boolean searchInAllMaps) {
    //      this.modeController = modeController;
    //      controller = modeController.getController();
    this.modal = modal;
    this.showAllNodes = showAllNodes;
    this.searchInAllMaps = searchInAllMaps;
    mFilterTextSearchField = new JComboBox();
    mFilterTextSearchField.setEditable(true);
    final FilterTextDocumentListener listener = new FilterTextDocumentListener();
    mFilterTextSearchField.addActionListener(listener);
    final JTextComponent editorComponent = (JTextComponent) mFilterTextSearchField.getEditor()
            .getEditorComponent();/*  w  ww  .j a  v  a  2s.  co  m*/
    editorComponent.getDocument().addDocumentListener(listener);
    mFilterTextSearchField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent pEvent) {
            if (pEvent.getKeyCode() == KeyEvent.VK_DOWN) {
                mFilterTextReplaceField.requestFocusInWindow();
            }
        }
    });
    mFilterTextReplaceField = new JComboBox();
    mFilterTextReplaceField.setEditable(true);
    mFilterTextReplaceField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent pEvent) {
            if (pEvent.getKeyCode() == KeyEvent.VK_DOWN) {
                tableView.requestFocusInWindow();
            } else if (pEvent.getKeyCode() == KeyEvent.VK_UP) {
                mFilterTextSearchField.requestFocusInWindow();
            }
        }
    });
    useRegexInReplace = new JCheckBox();
    useRegexInFind = new JCheckBox();
    useRegexInFind.addChangeListener(listener);
    matchCase = new JCheckBox();
    matchCase.addChangeListener(listener);
    final MapChangeListener mapChangeListener = new MapChangeListener();
    final ModeController modeController = Controller.getCurrentModeController();
    final MapController mapController = modeController.getMapController();
    mapController.addMapChangeListener(mapChangeListener);
    mapController.addNodeChangeListener(mapChangeListener);
    Controller.getCurrentController().getMapViewManager().addMapSelectionListener(mapChangeListener);

}

From source file:Report_PRCR_New_ETF_Excel_File_Generator.java

private void yearfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_yearfieldKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_UP) {
        yearfield.setText("" + (Integer.parseInt(yearfield.getText()) + 1));
        yearfield.selectAll();// w  w  w.  java  2 s. c  om
    }
    if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
        yearfield.setText("" + (Integer.parseInt(yearfield.getText()) - 1));
        yearfield.selectAll();
    }
    if (evt.getKeyCode() == KeyEvent.VK_LEFT) {
        monthfield.requestFocus();
        monthfield.selectAll();
    }

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) { ////// ChaNGE  focus on enter////////////////
        //   dayfield2.requestFocus();
        //  dayfield2.selectAll();

    }
}

From source file:net.sf.jabref.gui.groups.GroupSelector.java

/**
 * The first element for each group defines which field to use for the quicksearch. The next two define the name and
 * regexp for the group.//www  . ja  v a 2 s.c o  m
 */
public GroupSelector(JabRefFrame frame, SidePaneManager manager) {
    super(manager, IconTheme.JabRefIcon.TOGGLE_GROUPS.getIcon(), Localization.lang("Groups"));

    this.frame = frame;
    hideNonHits = new JRadioButtonMenuItem(Localization.lang("Hide non-hits"),
            !Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS));
    grayOut = new JRadioButtonMenuItem(Localization.lang("Gray out non-hits"),
            Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS));
    ButtonGroup nonHits = new ButtonGroup();
    nonHits.add(hideNonHits);
    nonHits.add(grayOut);
    floatCb.addChangeListener(
            event -> Globals.prefs.putBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS, floatCb.isSelected()));
    andCb.addChangeListener(event -> Globals.prefs.putBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS,
            andCb.isSelected()));
    invCb.addChangeListener(
            event -> Globals.prefs.putBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS, invCb.isSelected()));
    showOverlappingGroups.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING,
                    showOverlappingGroups.isSelected());
            if (!showOverlappingGroups.isSelected()) {
                groupsTree.setOverlappingGroups(Collections.emptyList());
            }
        }
    });

    grayOut.addChangeListener(
            event -> Globals.prefs.putBoolean(JabRefPreferences.GRAY_OUT_NON_HITS, grayOut.isSelected()));

    JRadioButtonMenuItem highlCb = new JRadioButtonMenuItem(Localization.lang("Highlight"), false);
    if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS)) {

        floatCb.setSelected(true);
        highlCb.setSelected(false);
    } else {
        highlCb.setSelected(true);
        floatCb.setSelected(false);
    }
    JRadioButtonMenuItem orCb = new JRadioButtonMenuItem(Localization.lang("Union"), false);
    if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS)) {
        andCb.setSelected(true);
        orCb.setSelected(false);
    } else {
        orCb.setSelected(true);
        andCb.setSelected(false);
    }

    showNumberOfElements.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS,
                    showNumberOfElements.isSelected());
            if (groupsTree != null) {
                groupsTree.invalidate();
                groupsTree.repaint();
            }
        }
    });

    autoAssignGroup.addChangeListener(event -> Globals.prefs.putBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP,
            autoAssignGroup.isSelected()));

    invCb.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS));
    showOverlappingGroups.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING));
    editModeIndicator = Globals.prefs.getBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE);
    editModeCb.setSelected(editModeIndicator);
    showNumberOfElements.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS));
    autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));

    JButton openSettings = new JButton(IconTheme.JabRefIcon.PREFERENCES.getSmallIcon());
    settings.add(andCb);
    settings.add(orCb);
    settings.addSeparator();
    settings.add(invCb);
    settings.addSeparator();
    settings.add(editModeCb);
    settings.addSeparator();
    settings.add(grayOut);
    settings.add(hideNonHits);
    settings.addSeparator();
    settings.add(showOverlappingGroups);
    settings.addSeparator();
    settings.add(showNumberOfElements);
    settings.add(autoAssignGroup);
    openSettings.addActionListener(e -> {
        if (!settings.isVisible()) {
            JButton src = (JButton) e.getSource();
            showNumberOfElements
                    .setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS));
            autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));
            settings.show(src, 0, openSettings.getHeight());
        }
    });

    editModeCb.addActionListener(e -> setEditMode(editModeCb.getState()));

    JButton newButton = new JButton(IconTheme.JabRefIcon.ADD_NOBOX.getSmallIcon());
    int butSize = newButton.getIcon().getIconHeight() + 5;
    Dimension butDim = new Dimension(butSize, butSize);

    newButton.setPreferredSize(butDim);
    newButton.setMinimumSize(butDim);
    JButton helpButton = new HelpAction(Localization.lang("Help on groups"), HelpFile.GROUP).getHelpButton();
    helpButton.setPreferredSize(butDim);
    helpButton.setMinimumSize(butDim);
    JButton autoGroup = new JButton(IconTheme.JabRefIcon.AUTO_GROUP.getSmallIcon());
    autoGroup.setPreferredSize(butDim);
    autoGroup.setMinimumSize(butDim);
    openSettings.setPreferredSize(butDim);
    openSettings.setMinimumSize(butDim);
    Insets butIns = new Insets(0, 0, 0, 0);
    helpButton.setMargin(butIns);
    openSettings.setMargin(butIns);
    newButton.addActionListener(e -> {
        GroupDialog gd = new GroupDialog(frame, panel, null);
        gd.setVisible(true);
        if (gd.okPressed()) {
            AbstractGroup newGroup = gd.getResultingGroup();
            groupsRoot.addNewGroup(newGroup, panel.getUndoManager());
            panel.markBaseChanged();
            frame.output(Localization.lang("Created group \"%0\".", newGroup.getName()));
        }
    });
    andCb.addActionListener(e -> valueChanged(null));
    orCb.addActionListener(e -> valueChanged(null));
    invCb.addActionListener(e -> valueChanged(null));
    showOverlappingGroups.addActionListener(e -> valueChanged(null));
    autoGroup.addActionListener(e -> {
        AutoGroupDialog gd = new AutoGroupDialog(frame, panel, groupsRoot,
                Globals.prefs.get(JabRefPreferences.GROUPS_DEFAULT_FIELD), " .,",
                Globals.prefs.get(JabRefPreferences.KEYWORD_SEPARATOR));
        gd.setVisible(true);
        // gd does the operation itself
    });
    floatCb.addActionListener(e -> valueChanged(null));
    highlCb.addActionListener(e -> valueChanged(null));
    hideNonHits.addActionListener(e -> valueChanged(null));
    grayOut.addActionListener(e -> valueChanged(null));
    newButton.setToolTipText(Localization.lang("New group"));
    andCb.setToolTipText(Localization.lang("Display only entries belonging to all selected groups."));
    orCb.setToolTipText(
            Localization.lang("Display all entries belonging to one or more of the selected groups."));
    autoGroup.setToolTipText(Localization.lang("Automatically create groups for database."));
    openSettings.setToolTipText(Localization.lang("Settings"));
    invCb.setToolTipText(
            "<html>" + Localization.lang("Show entries <b>not</b> in group selection") + "</html>");
    showOverlappingGroups.setToolTipText(Localization
            .lang("Highlight groups that contain entries contained in any currently selected group"));
    floatCb.setToolTipText(Localization.lang("Move entries in group selection to the top"));
    highlCb.setToolTipText(Localization.lang("Gray out entries not in group selection"));
    editModeCb.setToolTipText(Localization.lang("Click group to toggle membership of selected entries"));
    ButtonGroup bgr = new ButtonGroup();
    bgr.add(andCb);
    bgr.add(orCb);
    ButtonGroup visMode = new ButtonGroup();
    visMode.add(floatCb);
    visMode.add(highlCb);

    JPanel rootPanel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    rootPanel.setLayout(gbl);

    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.BOTH;
    con.weightx = 1;
    con.gridwidth = 1;
    con.gridy = 0;

    con.gridx = 0;
    gbl.setConstraints(newButton, con);
    rootPanel.add(newButton);

    con.gridx = 1;
    gbl.setConstraints(autoGroup, con);
    rootPanel.add(autoGroup);

    con.gridx = 2;
    gbl.setConstraints(openSettings, con);
    rootPanel.add(openSettings);

    con.gridx = 3;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(helpButton, con);
    rootPanel.add(helpButton);

    groupsTree = new GroupsTree(this);
    groupsTree.addTreeSelectionListener(this);

    JScrollPane groupsTreePane = new JScrollPane(groupsTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    groupsTreePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weighty = 1;
    con.gridx = 0;
    con.gridwidth = 4;
    con.gridy = 1;
    gbl.setConstraints(groupsTreePane, con);
    rootPanel.add(groupsTreePane);

    add(rootPanel, BorderLayout.CENTER);
    setEditMode(editModeIndicator);
    definePopup();
    NodeAction moveNodeUpAction = new MoveNodeUpAction();
    moveNodeUpAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_MASK));
    NodeAction moveNodeDownAction = new MoveNodeDownAction();
    moveNodeDownAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_MASK));
    NodeAction moveNodeLeftAction = new MoveNodeLeftAction();
    moveNodeLeftAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_MASK));
    NodeAction moveNodeRightAction = new MoveNodeRightAction();
    moveNodeRightAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_MASK));

    setGroups(GroupTreeNode.fromGroup(new AllEntriesGroup()));
}

From source file:org.slage.tests.ImageTest.java

/** Initialize the stuff */
public void initialize() {
    super.initialize();

    // Make a VSL, and add it to the game
    VerbSynonymList takelist = new VerbSynonymList("take");
    takelist.add("grab");
    takelist.add("pick up");
    takelist.add("snatch");
    this.applyVerbSynonymList(takelist);

    // every game needs a player
    SlagePlayer player = new SlagePlayer("Roger Wilco", "SQ7 Testing Team");
    player.setSceneImage(new SlageImage("org?slage?tests?content?roger_eva.jpg"));
    player.setClickBoundary(new Boundary(player.getSceneImage(), 10));
    player.setZ(10);//from  w ww .j  av  a2s  .c o  m
    player.useClickBoundaryForCollision();

    AsyncKeyAction akaN = new AsyncKeyAction("North", new TranslateHandler(player, 0, -4));
    akaN.addKey(KeyEvent.VK_UP);

    AsyncKeyAction akaS = new AsyncKeyAction("South", new TranslateHandler(player, 0, 4));
    akaS.addKey(KeyEvent.VK_DOWN);

    AsyncKeyAction akaW = new AsyncKeyAction("West", new TranslateHandler(player, -4, 0));
    akaW.addKey(KeyEvent.VK_LEFT);

    AsyncKeyAction akaE = new AsyncKeyAction("East", new TranslateHandler(player, 4, 0));
    akaE.addKey(KeyEvent.VK_RIGHT);

    addAsyncAction(akaN);
    addAsyncAction(akaW);
    addAsyncAction(akaE);
    addAsyncAction(akaS);

    setPlayer(player);

    setAttribute("Debug Mode", new Boolean(false));

    ResponseHandler rlook = new ResponseHandler(player, "It's you!", null);
    rlook.addVerb("look");
    player.addHandler(rlook);
    ResponseHandler rlick = new ResponseHandler(player, "You lick yourself.", null);
    rlick.addVerb("Lick");
    rlick.addVerb("Kiss");
    player.addHandler(rlick);
    ResponseHandler rtake = new ResponseHandler(player, "This is a family game!", null);
    rtake.addVerb("Take");
    rtake.addVerb("Touch");
    player.addHandler(rtake);

    // set the default cursor
    getToolbar().setDefaultCursor(new SlageImage("org?slage?tests?content?sqcursor.PNG"));

    // make a fake Room
    room = new Room("Monolith Burger");
    room.setSceneImage(new SlageImage("org?slage?tests?content?monolith_scrollhall.jpg"));
    room.addObject(player);

    ResponseHandler look = new ResponseHandler(room,
            "A Monolith Burger! You haven't seen one of these in two or three sequels!", strMonolith);
    ResponseHandler lick = new ResponseHandler(room,
            "Having worked in a Monolith Burger once, you should know they are not sanitary enough to lick.",
            null);
    look.addVerb("look");
    look.addVerb("examine");
    lick.addVerb("lick");
    lick.addVerb("taste");
    room.addHandler(look);
    room.addHandler(lick);

    tryTheSpecial = new TextObject("Try the special!", new Font("Arial", 1, 14), Color.BLACK,
            new Point3D(0, room.getDimensions().height - 300, 0));
    room.addObject(tryTheSpecial);

    // build objects
    makeDuke();
    makePope();
    makeToolButtons();
    makeBathrooms();
    makeBuckazoid();
    makeArcade();
    makeCandy();

    makePauseHandler();

    // set up scheduling
    makeEvents();

    // set current room and add objects in it to draw list
    addObject(room);
    setRoom(room);

    loadSound(strMonolith, false);
}

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

protected void setVisualiserKeyBindings() {
    persistAction = new graphAction("saveLayout", "save the layout of the visible graph") {

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

        @Override/*from www  .ja  v a  2s .c o  m*/
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            XMLEncoder encoder = null;
            try {
                if (propName >= 0) {
                    String fileName = getLayoutFileName(graphs.get(currentGraph));
                    encoder = new XMLEncoder(new FileOutputStream(fileName));
                    Map<Integer, DoublePair> layout = ((XMLPersistingLayout) viewer.getModel().getGraphLayout())
                            .persist();
                    encoder.writeObject(layout);
                    XMLAffineTransformSerialised trV = new XMLAffineTransformSerialised();
                    trV.setFromAffineTransform(viewer.getViewTransformer().getTransform());
                    encoder.writeObject(trV);
                    XMLAffineTransformSerialised trL = new XMLAffineTransformSerialised();
                    trL.setFromAffineTransform(viewer.getLayoutTransformer().getTransform());
                    encoder.writeObject(trL);
                    ((XMLModalGraphMouse) viewer.getGraphMouse()).store(encoder);
                    encoder.writeObject(layoutOptions.get(currentGraph));
                    encoder.close();
                    encoder = null;
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            } finally {
                if (encoder != null) {
                    encoder.close();
                    encoder = null;
                }
            }
        }
    };
    keyToActionMap.put(KeyEvent.VK_F2, persistAction);
    keyToActionMap.put(KeyEvent.VK_F3,
            new graphAction("loadLayout", "loads the previously saved layout into the visible graph") {

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

                @Override
                public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
                    reloadLayout(false, true);
                }
            });
    keyToActionMap.put(KeyEvent.VK_F9,
            new graphAction("loadPreviousLayout", "loads the layout of the previous graph in the list") {

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

                @Override
                public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
                    if (currentGraph > 0) {
                        restoreLayout(false, currentGraph - 1);
                    }
                }
            });

    pickAction = new graphAction("pick", "Switches Jung into picking mode") {

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

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            ((XMLModalGraphMouse) viewer.getGraphMouse()).setMode(ModalGraphMouse.Mode.PICKING);
        }
    };
    keyToActionMap.put(KeyEvent.VK_F11, pickAction);

    transformAction = new graphAction("transform", "Switches Jung into transformation mode") {

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

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            ((XMLModalGraphMouse) viewer.getGraphMouse()).setMode(ModalGraphMouse.Mode.TRANSFORMING);
        }
    };
    keyToActionMap.put(KeyEvent.VK_F12, transformAction);

    keyToActionMap.put(KeyEvent.VK_UP, new graphAction("previous", "loads the previous graph") {

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

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            if (currentGraph > 0) {
                --currentGraph;
                reloadLayout(false, true);
            }
        }
    });
    keyToActionMap.put(KeyEvent.VK_DOWN, new graphAction("next", "loads the next graph") {

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

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            if (currentGraph < graphs.size() - 1) {
                ++currentGraph;
                reloadLayout(false, true);
            }
        }
    });

    keyToActionMap.put(KeyEvent.VK_F, new graphAction("negatives", "toggles negatives on or off") {

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

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            LayoutOptions options = layoutOptions.get(currentGraph);
            if (options != null) {
                options.showNegatives = !options.showNegatives;
                reloadLayout(false, false);
            }
        }
    });
    keyToActionMap.put(KeyEvent.VK_I, new graphAction("ignored states", "toggles ignored states on or off") {

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

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            LayoutOptions options = layoutOptions.get(currentGraph);
            if (options != null) {
                options.showIgnored = !options.showIgnored;
                reloadLayout(false, false);
            }
        }
    });
    keyToActionMap.put(KeyEvent.VK_PAGE_DOWN, new graphAction("refine", "reduces the abstraction level") {

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

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            LayoutOptions options = layoutOptions.get(currentGraph);
            if (options != null && options.componentsToPick < Integer.MAX_VALUE) {
                options.componentsToPick++;
                reloadLayout(false, false);
            }
        }
    });
    keyToActionMap.put(KeyEvent.VK_PAGE_UP, new graphAction("abstract", "increases abstraction level") {

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

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            LayoutOptions options = layoutOptions.get(currentGraph);
            if (options != null && options.componentsToPick != Integer.MAX_VALUE
                    && options.componentsToPick > 0) {
                --options.componentsToPick;
                reloadLayout(false, false);
            }
        }
    });
}

From source file:ucar.unidata.idv.control.chart.PlotWrapper.java

/**
 * Handle event/*from  w  w  w .  j  ava2  s.  co m*/
 *
 * @param e The event
 */
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
        panPlot(true);
    } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
        panPlot(false);
    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
        upDownPlot(true);
    } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
        upDownPlot(false);
    } else if ((e.getKeyCode() == KeyEvent.VK_R) && e.isControlDown()) {
        resetPlot();
    } else {
        super.keyPressed(e);
    }
}

From source file:org.pmedv.blackboard.components.BoardEditor.java

/**
 * Wire needed actions with the keyboard
 *///ww  w .j a v  a 2 s.c o  m
@SuppressWarnings("serial")
private void initActions() {

    // keyboard associations

    ApplicationWindow window = AppContext.getBean(ApplicationWindow.class);
    //      
    //      window.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "upAction");
    //      window.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "downAction");
    //      window.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "leftAction");
    //      window.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "rightAction");
    //
    //      window.getRootPane().getActionMap().put("upAction", new AbstractAction() {
    //         public void actionPerformed(ActionEvent event) {
    //            moveItemByKey("up");
    //         }
    //      });
    //      window.getRootPane().getActionMap().put("downAction", new AbstractAction() {
    //         public void actionPerformed(ActionEvent event) {
    //            moveItemByKey("down");
    //         }
    //      });
    //      window.getRootPane().getActionMap().put("leftAction", new AbstractAction() {
    //         public void actionPerformed(ActionEvent event) {
    //            moveItemByKey("left");
    //         }
    //      });
    //      window.getRootPane().getActionMap().put("rightAction", new AbstractAction() {
    //         public void actionPerformed(ActionEvent event) {
    //            moveItemByKey("right");
    //         }
    //      });

    registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            moveItemByKey("up");
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

    registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            moveItemByKey("down");
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

    registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            moveItemByKey("left");
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

    registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            moveItemByKey("right");
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

}