Java 类java.awt.event.KeyEvent 实例源码

项目:sumo    文件:GeometricInteractiveVDSLayerPanel.java   
public void keyReleased(KeyEvent e) {
    FlagTable t=(FlagTable)e.getSource();
    int id = e.getID();
    if(id == e.KEY_RELEASED && e.getKeyChar() == e.VK_BACK_SPACE)
    {
        if(t.getSelectedRow() != -1)
            for(int i:t.getSelectedRows()){
                GeometryImage gl=((ComplexEditVDSVectorLayer)layer).getGeometriclayer();
                Geometry geom=gl.getGeometries().get(i);
                deleted.add(0,geom);
                attrDeleted.add(0,(gl).getAttributes(geom));
                ((GeometricInteractiveVDSLayerModel)t.getModel()).removeSelection(i);
                glm.fireTableDataChanged();
                if(gl.getGeometries().size()>0){
                    int sel=0;
                    if(i>0&&i<(gl.getGeometries().size()-1))
                        sel=i;
                    ((GeometricInteractiveVDSLayerModel)t.getModel()).changeSelection(sel, display);
                    glm.changeSelection(sel, true);
                    ((JTable)e.getSource()).setRowSelectionInterval(sel,sel);
                }
            }
        this.repaint();
        ((GeometricInteractiveVDSLayerModel)t.getModel()).changeSelection(t.getSelectedRow(), display);
    }
}
项目:PassBox    文件:Login_Page.java   
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode()==KeyEvent.VK_ENTER){
        String sorgu = "SELECT * FROM passbox_db.users_tb where username=? and password=?;";
    try {
        pst=baglanti.prepareStatement(sorgu);
        pst.setString(1, username_txt.getText());
        pst.setString(2, password_txt.getText());
        gelenveri=pst.executeQuery();
        if(gelenveri.next()){
            JOptionPane.showMessageDialog(null,"Başarılı giriş!");
            this.setVisible(false);
            User_Control_Panel_Page frame = new User_Control_Panel_Page();
            frame.setVisible(true);
        }
        else{
        JOptionPane.showMessageDialog(null,"Başarısız giriş!");
        }
    } catch (SQLException ex) {
        JOptionPane.showConfirmDialog(null, "Sorgu da hata var!");
    }
    }
}
项目:vexillo    文件:CopySVGMenuItem.java   
public CopySVGMenuItem(final FlagFrame frame) {
    setText("Copy SVG");
    if (!OSUtils.isMacOS()) setMnemonic(KeyEvent.VK_S);
    setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputUtils.META_SHIFT_MASK));
    if (frame == null) {
        setEnabled(false);
    } else {
        addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                SVGExporter s = new SVGExporter(frame.getFlagFile(), frame.getFlag());
                String svg = s.exportToString(frame.getViewerWidth(), frame.getViewerHeight(), frame.getGlaze());
                StringSelection ss = new StringSelection(svg);
                Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
                cb.setContents(ss, ss);
            }
        });
    }
}
项目:jaer    文件:IPotSliderTextControl.java   
private void valueTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueTextFieldKeyPressed
        // key pressed in text field
        //        System.out.println("keyPressed evt "+evt);
//        System.out.println("value field key pressed");
        endEdit();
//        String s = evt.getKeyText(evt.getKeyCode());
        int code = evt.getKeyCode();
        boolean shift = evt.isShiftDown();
        float byRatio = 1.1f;
        if (shift) {
            byRatio = 10f;
        }
        if (code == KeyEvent.VK_UP) {
            startEdit();
            pot.changeByRatio(byRatio);
            endEdit();
        } else if (code == KeyEvent.VK_DOWN) {
            startEdit();
            pot.changeByRatio(1f / byRatio);
            endEdit();
        }
    }
项目:incubator-netbeans    文件:CheckListener.java   
public void keyPressed(KeyEvent e) {
    if (e.getKeyChar() == ' ') {
        JTree tree = (JTree) e.getSource();
        TreePath path = tree.getSelectionPath();
        if( null == path )
            return;

        Node node = Visualizer.findNode( path.getLastPathComponent() );
        if( null == node )
            return;

        boolean isSelected = settings.isNodeVisible( node );
        settings.setNodeVisible( node, !isSelected );
        tree.repaint();

        e.consume();
    }
}
项目:incubator-netbeans    文件:FixImportsTest.java   
public void testCancel() {
    Node pn = new ProjectsTabOperator().getProjectRootNode(TEST_PROJECT_NAME);
    pn.select();

    Node n = new Node(pn, org.netbeans.jellytools.Bundle.getString(
            "org.netbeans.modules.java.j2seproject.Bundle",
            "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|"
            +TEST_CLASS_NAME);
    n.select();
    new OpenAction().perform();
    EditorOperator editor = new EditorOperator(TEST_CLASS_NAME);
    try {
        editor.insert("List m;\n", 46, 1);
        Utilities.takeANap(100);
        MainWindowOperator.getDefault().pushKey(KeyEvent.VK_I,
                KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK);            
        FixAllImports fio = new FixAllImports();
        fio.cancel();
        assertFalse("Import is added",editor.getText().contains("import java.util.List;"));
    } finally {
        editor.close(false);
    }
}
项目:smile_1.5.0_java7    文件:FontChooser.java   
@Override
public void keyPressed(KeyEvent e) {
    switch (e.getKeyCode()) {
        case KeyEvent.VK_UP:
            int up = targetList.getSelectedIndex() - 1;
            if (up < 0) {
                up = 0;
            }
            targetList.setSelectedIndex(up);
            break;
        case KeyEvent.VK_DOWN:
            int listSize = targetList.getModel().getSize();
            int down = targetList.getSelectedIndex() + 1;
            if (down >= listSize) {
                down = listSize - 1;
            }
            targetList.setSelectedIndex(down);
            break;
        default:
            break;
    }
}
项目:AgentWorkbench    文件:TableCellSpinnerEditor4FloatObject.java   
@Override
public void keyPressed(KeyEvent e) {
    if(e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_TAB){
        try {
            ((JSpinner)editorComponent).commitEdit();

        } catch (ParseException e1) {
            DefaultEditor de = (DefaultEditor) ((JSpinner)editorComponent).getEditor();
            String text = de.getTextField().getText();
            if(text.matches("^\\d+(\\.\\d*)?")){
                ((JSpinner)editorComponent).setValue(Float.parseFloat(text));
            }else{
                System.err.println("Invalid input - ignoring");
            }
        }
    }
    super.keyPressed(e);
}
项目:Logisim    文件:MemPoker.java   
@Override
public void keyTyped(InstanceState state, KeyEvent e) {
    char c = e.getKeyChar();
    int val = Character.digit(e.getKeyChar(), 16);
    MemState data = (MemState) state.getData();
    if (val >= 0) {
        curValue = curValue * 16 + val;
        data.getContents().set(data.getCursor(), curValue);
        state.fireInvalidated();
    } else if (c == ' ' || c == '\t') {
        moveTo(data, data.getCursor() + 1);
    } else if (c == '\r' || c == '\n') {
        moveTo(data, data.getCursor() + data.getColumns());
    } else if (c == '\u0008' || c == '\u007f') {
        moveTo(data, data.getCursor() - 1);
    }
}
项目:openjdk-jdk10    文件:bug4524490.java   
public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    robot.setAutoDelay(50);

    UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");

    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            fileChooser = new JFileChooser();
            fileChooser.showOpenDialog(null);
        }
    });

    robot.waitForIdle();

    if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) {
        Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L);
    } else {
        Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_L);
    }
    checkFocus();
}
项目:scorekeeperfrontend    文件:RunsTable.java   
public RunsTable(EntryModel m)
{
    super(m, new TimeRenderer(), new RunsTransferHandler(), 2, Integer.MAX_VALUE);

    InputMap im = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "cut"); // delete is same as Ctl+X
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter Time");

    registerKeyboardAction(
        this,
        "Enter Time",
        KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
    );

    Messenger.register(MT.TIME_ENTERED, this);
}
项目:jaer    文件:ConfigurableIPotGUIControl.java   
private void biasTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_biasTextFieldKeyPressed
        int code = evt.getKeyCode();
        boolean shifted = evt.isShiftDown();
        final float byRatio = 1.02f;
        if (code == KeyEvent.VK_UP) {
            startEdit();
            if (shifted) {
                pot.setBitValue(pot.getBitValue() + 1);
            } else {
                pot.changeByRatio(byRatio);
            }
            endEdit();
        } else if (code == KeyEvent.VK_DOWN) {
            startEdit();
            if (shifted) {
                pot.setBitValue(pot.getBitValue() - 1);
            } else {
                pot.changeByRatio(1f / byRatio);
            }
            endEdit();
        }
}
项目:incubator-netbeans    文件:Utilities.java   
/**
 * Creates nice textual representation of KeyStroke.
 * Modifiers and an actual key label are concated by plus signs
 * @param the KeyStroke to get description of
 * @return String describing the KeyStroke
 */
public static String keyStrokeToString( KeyStroke stroke ) {
    String modifText = KeyEvent.getKeyModifiersText( stroke.getModifiers() );
    String keyText = (stroke.getKeyCode() == KeyEvent.VK_UNDEFINED) ? 
        String.valueOf(stroke.getKeyChar()) : getKeyText(stroke.getKeyCode());
    if( modifText.length() > 0 ) return modifText + '+' + keyText;
    else return keyText;
}
项目:openjdk-jdk10    文件:AWTTextKeyboardDriver.java   
@Override
public NavigationKey[] getKeys(ComponentOperator oper) {
    boolean multiString = oper instanceof TextAreaOperator;
    NavigationKey[] result = new NavigationKey[multiString ? 4 : 2];
    result[0] = new UpKey(KeyEvent.VK_LEFT, 0);
    result[1] = new DownKey(KeyEvent.VK_RIGHT, 0);
    ((UpKey) result[0]).setDownKey((DownKey) result[1]);
    ((DownKey) result[1]).setUpKey((UpKey) result[0]);
    if (multiString) {
        result[2] = new UpKey(KeyEvent.VK_UP, 0);
        result[3] = new DownKey(KeyEvent.VK_DOWN, 0);
        ((UpKey) result[2]).setDownKey((DownKey) result[3]);
        ((DownKey) result[3]).setUpKey((UpKey) result[2]);
    }
    return result;
}
项目:incubator-netbeans    文件:IncrementalSearchTest.java   
public void testNotFound() {
    openDefaultProject();
    openFile("Source Packages|org.netbeans.test.editor.search.IncrementalSearchTest", "match.txt");
    EditorOperator editor = new EditorOperator("match.txt");
    editor.setCaretPosition(3, 1);
    SearchBarOperator barOperator = SearchBarOperator.invoke(editor);
    JTextComponentOperator t = barOperator.findCombo();
    try {            
        t.clearText();
        new EventTool().waitNoEvent(100);
        t.requestFocus();
        t.typeText("XYZ");        
        t.pushKey(KeyEvent.VK_ENTER);                        
        new EventTool().waitNoEvent(100);            
        MainWindowOperator mwo =  MainWindowOperator.getDefault();
        assertEquals("'XYZ' not found",mwo.getStatusText());                        
        JTextComponentOperator filed = barOperator.findCombo();
        assertEquals(new Color(178, 0, 0), filed.getForeground());                
    } finally {
        barOperator.closeButton().doClick();                              
    }
    new EventTool().waitNoEvent(200);
    assertFalse("ToolBar not closed",barOperator.isVisible());
    editor.closeDiscard();
}
项目:openjdk-jdk10    文件:TextKeyboardDriver.java   
@Override
public void clearText(ComponentOperator oper) {
    DriverManager.getFocusDriver(oper).giveFocus(oper);
    checkSupported(oper);
    KeyDriver kdriver = DriverManager.getKeyDriver(oper);
    Timeout pushTime = oper.getTimeouts().create("ComponentOperator.PushKeyTimeout");
    Timeout betweenTime = getBetweenTimeout(oper);
    while (getCaretPosition(oper) > 0) {
        kdriver.typeKey(oper, KeyEvent.VK_BACK_SPACE, (char) KeyEvent.VK_BACK_SPACE, 0, pushTime);
        betweenTime.sleep();
    }
    while (getText(oper).length() > 0) {
        kdriver.pushKey(oper, KeyEvent.VK_DELETE, 0, pushTime);
        betweenTime.sleep();
    }
}
项目:AI-RRT-Motion-Planning    文件:Visualiser.java   
private void createFileMenu() {
    fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    fileMenu.getAccessibleContext().setAccessibleDescription(
            "Load configs or close the app.");
    menuBar.add(fileMenu);

    loadProblemItem = new JMenuItem("Load problem");
    loadProblemItem.setMnemonic(KeyEvent.VK_P);
    loadProblemItem.addActionListener(menuListener);
    fileMenu.add(loadProblemItem);

    loadSolutionItem = new JMenuItem("Load solution");
    loadSolutionItem.setMnemonic(KeyEvent.VK_S);
    loadSolutionItem.addActionListener(menuListener);
    loadSolutionItem.setEnabled(false);
    fileMenu.add(loadSolutionItem);

    fileMenu.addSeparator();
    exitItem = new JMenuItem("Exit");
    exitItem.setMnemonic(KeyEvent.VK_X);
    exitItem.addActionListener(menuListener);
    fileMenu.add(exitItem);
}
项目:incubator-netbeans    文件:RemoveSurroundingTest.java   
private void dumpAndSelect(int row, int col, int select) {
    oper.setCaretPosition(row, col);
    oper.pressKey(KeyEvent.VK_BACK_SPACE, KeyEvent.ALT_DOWN_MASK);
    JDialogOperator jdo = new JDialogOperator(MainWindowOperator.getDefault());
    JListOperator jlo = new JListOperator(jdo);
    ListModel model = jlo.getModel();
    int i;
    for (i = 0; i < model.getSize(); i++) {
        Object item = model.getElementAt(i);
        if(item instanceof CodeDeleter) {
            CodeDeleter codeDeleter = (CodeDeleter) item;
            ref(codeDeleter.getDisplayName());                
            HighlightsSequence highlights = codeDeleter.getHighlight().getHighlights(0, oper.getText().length());
            while(highlights.moveNext()) {
                ref(highlights.getStartOffset()+" "+highlights.getEndOffset());
                AttributeSet attributes = highlights.getAttributes();
                Enumeration<?> attributeNames = attributes.getAttributeNames();
                while(attributeNames.hasMoreElements()) {
                    Object nextElement = attributeNames.nextElement();
                    ref(nextElement+" "+attributes.getAttribute(nextElement));
                }
            }
        }            
    }
    if(select>-1) {
        jlo.selectItem(select);
        ref(oper.getText());
    }        
}
项目:openjdk-jdk10    文件:TestPopupMenu.java   
public TestPopupMenu() throws Exception {
    Robot robot = new Robot();
    robot.setAutoDelay(200);
    try {
        SwingUtilities.invokeAndWait(() -> {
            try {
                createAndShowUI();
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        });
        blockTillDisplayed(label);
        robot.waitForIdle();
        robot.mouseMove(p.x + d.width/2, p.y + d.height/2);
        robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
        robot.waitForIdle();
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_U);
        robot.keyRelease(KeyEvent.VK_U);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.waitForIdle();
        JPopupMenu popup = label.getComponentPopupMenu();
        if (popup != null && popup.isVisible()) {
            throw new RuntimeException("Popup is visible in wrong internal frame");
        }
    } finally {
        SwingUtilities.invokeAndWait(()->frame.dispose());
    }
}
项目:incubator-netbeans    文件:FilterUtils.java   
public KeyStroke registerAction(String actionKey, Action action, ActionMap actionMap, InputMap inputMap) {
    if (!FILTER_ACTION_KEY.equals(actionKey)) return null;

    KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK);
    actionMap.put(actionKey, action);
    inputMap.put(ks, actionKey);

    return ks;
}
项目:incubator-netbeans    文件:TopComponentTest.java   
public void testToStringOfDelegateContainsNameOfOriginalAction() throws Exception {
    SaveAction sa = SaveAction.get(SaveAction.class);
    Action a = sa.createContextAwareInstance(Lookup.EMPTY);
    if (a.toString().indexOf("SaveAction") == -1) {
        fail("We need name of the original action:\n" + a.toString());
    }

    SaveAction.cnt = 0;
    CharSequence log = Log.enable("org.netbeans.ui", Level.FINER);

    final TopComponent tc = new TopComponent();
    final KeyEvent ke = new KeyEvent(tc, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.CTRL_MASK, 0, 'S');
    final KeyStroke ks = KeyStroke.getKeyStrokeForEvent(ke);
    MockServices.setServices(MyKM.class);
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            tc.setActivatedNodes( new Node[0] );
            tc.processKeyBinding(ks, ke, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, true);
        }

    });

    if (log.toString().indexOf("SaveAction") == -1 
            && SaveAction.cnt == 1 ) { //make sure the action was actually invoked
        fail(log.toString());
    }
}
项目:incubator-netbeans    文件:ListView.java   
public Object run() {
    switch (type) {
        case 0:
            NbList.super.paint((Graphics) p1);
            break;
        case 1:
            NbList.super.validateTree();
            break;
        case 2:
            doLayoutImpl();
            break;
        case 3:
            repaintSelection();
            break;
        case 4:
            NbList.super.processEvent((AWTEvent) p1);
            break;
        case 5:
            return NbList.super.getPreferredSize();
        case 6:
            return getToolTipTextImpl((MouseEvent) p1);
        case 7:
            return NbList.super.indexToLocation((Integer) p1);
        case 8:
            return NbList.super.locationToIndex((Point) p1);
        case 9:
            return NbList.super.getSelectedValues();
        case 10:
            Object[] arr = (Object[]) p1;
            return NbList.super.processKeyBinding(
                    (KeyStroke) arr[0],
                    (KeyEvent) arr[1],
                    (Integer) arr[2],
                    (Boolean) arr[3]);                      
        default:
            throw new IllegalStateException("type: " + type);
    }

    return null;
}
项目:ClipIt    文件:ClipboardUtils.java   
public static void paste() {
  try {
    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_V);
    robot.keyRelease(KeyEvent.VK_V);
    robot.keyRelease(KeyEvent.VK_CONTROL);
    // System.out.println("paste...");
  } catch (AWTException e) {
    e.printStackTrace();
  }
}
项目:JuggleMasterPro    文件:MarkJComboBox.java   
/**
 * Constructs
 * 
 * @param objPcontrolJFrame
 * @param bytPfilterType
 * @param bolPglobal
 */
public MarkJComboBox(ControlJFrame objPcontrolJFrame, byte bytPfilterType, boolean bolPglobal) {
    this.objGcontrolJFrame = objPcontrolJFrame;
    this.bytGfilterType = bytPfilterType;
    this.bolGglobal = bolPglobal;
    this.setFont(this.objGcontrolJFrame.getFont());
    this.setOpaque(true);
    this.setBackground(Constants.objS_PEN_COLORS_LIGHT_YELLOW_COLOR);
    this.setRenderer(Constants.objS_GRAPHICS_DEFAULT_RENDERER);
    this.setList();
    this.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), KeyEvent.VK_ENTER);
    this.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), KeyEvent.VK_SPACE);
    this.getActionMap()
        .put(   KeyEvent.VK_ENTER,
                new KeysAction( objPcontrolJFrame,
                                bolPglobal ? bytPfilterType == Constants.bytS_BYTE_GLOBAL_LOW_MARK ? KeysAction.bytS_LOW_MARK_J_COMBO_BOX
                                                                                                    : KeysAction.bytS_HIGH_MARK_J_COMBO_BOX
                                            : KeysAction.bytS_MARK_J_COMBO_BOX));
    this.getActionMap()
        .put(   KeyEvent.VK_SPACE,
                new KeysAction( objPcontrolJFrame,
                                bolPglobal ? bytPfilterType == Constants.bytS_BYTE_GLOBAL_LOW_MARK ? KeysAction.bytS_LOW_MARK_J_COMBO_BOX
                                                                                                    : KeysAction.bytS_HIGH_MARK_J_COMBO_BOX
                                            : KeysAction.bytS_MARK_J_COMBO_BOX,
                                KeyEvent.VK_SPACE));
    this.addPopupMenuListener(this);
    this.addActionListener(this);
}
项目:incubator-netbeans    文件:CodeFoldingTestCase.java   
protected void collapseAllFolds(EditorOperator editor){
    // hit CTRL Shift -
    JEditorPaneOperator txtOper = editor.txtEditorPane();
    txtOper.pushKey(KeyEvent.VK_SUBTRACT, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);

    // wait a while
    try {
        Thread.currentThread().sleep(COLLAPSE_EXPAND_DELAY);
    } catch (InterruptedException ex) {
    }
}
项目:incubator-netbeans    文件:JavaEditActionsTest.java   
public void testEditActionsTestCase_17() {
    openFileAndSetEditorState("testEditActions", "testEditActions16.pass", 10, 34);
    /// 17 -- test expanding abbreviation
    editor.setCaretPosition(19, 12);
    txtOper.typeKey('s');
    txtOper.typeKey('t');
    txtOper.pressKey(KeyEvent.VK_TAB);
    compareToGoldenFile(editor, "testEditActionsTestCase_1700", "testEditActions17", "testEditActions17");
}
项目:incubator-netbeans    文件:WatchAnnotationProvider.java   
@Override
public void keyReleased(KeyEvent e) {
    if (!(e.isAltDown() || e.isAltGraphDown() ||
          e.isControlDown() || e.isMetaDown() ||
          e.isShiftDown())) {

        unsetSelectCursor();
    }
}
项目:jmt    文件:SaveModel.java   
/**
 * Defines an <code>Action</code> object with a default
 * description string and default icon.
 */
public SaveModel(Mediator mediator) {
    super("Save", "Save", mediator);
    putValue(SHORT_DESCRIPTION, "Save this model");
    putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_S));
    putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
    setEnabled(false);
}
项目:incubator-netbeans    文件:ContextAwareActionInTopComponentTest.java   
public void testGlobalActionDoesNotSurviveFocusChange() throws Exception {
    myGlobalAction.setEnabled( true );

    final org.openide.nodes.Node n = new org.openide.nodes.AbstractNode (org.openide.nodes.Children.LEAF);
    tc.setActivatedNodes(new Node[0]);

    KeyEvent e = new KeyEvent( tc, KeyEvent.KEY_TYPED, 0, 0, 0 );
    assertTrue( tc.processKeyBinding( KEY_STROKE, e, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, true ) );
    assertTrue( MyContextAwareAction.globalActionWasPerformed );
    assertFalse( MyContextAwareAction.contextActionWasPerformed );
}
项目:incubator-netbeans    文件:ComboTest.java   
private void typeKey(final Component target, final int key) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            KeyEvent ke = new KeyEvent(target, KeyEvent.KEY_TYPED, System.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, (char) key);
            target.dispatchEvent(ke);
        }
    });
    sleep();
}
项目:incubator-netbeans    文件:FixImportsTest.java   
public void testRemoveAndAdd() {
    Node pn = new ProjectsTabOperator().getProjectRootNode(TEST_PROJECT_NAME);
    pn.select();

    Node n = new Node(pn, org.netbeans.jellytools.Bundle.getString(
            "org.netbeans.modules.java.j2seproject.Bundle",
            "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|"
            +TEST_CLASS_NAME);
    n.select();
    new OpenAction().perform();
    EditorOperator editor = new EditorOperator(TEST_CLASS_NAME);
    try {
        editor.insert("import java.util.Date;\n", 41, 1);
        editor.insert("List m;\n", 47, 1);
        Utilities.takeANap(100);
        MainWindowOperator.getDefault().pushKey(KeyEvent.VK_I,
                KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK);

        FixAllImports fio = new FixAllImports();
        fio.cbRemoveUnusedImports().changeSelection(true);
        fio.ok();
        Utilities.takeANap(500);
        assertFalse("Import is not removed",editor.getText().contains("import java.util.Date;"));
        assertTrue("Import is not added",editor.getText().contains("import java.util.List;"));
    } finally {
        editor.close(false);
    }

}
项目:incubator-netbeans    文件:CompletionLayout.java   
public void processKeyEvent(KeyEvent evt) {
    if (isVisible()) {
        Object actionMapKey = completionScrollPane.getInputMap().get(
                KeyStroke.getKeyStrokeForEvent(evt));

        if (actionMapKey != null) {
            Action action = completionScrollPane.getActionMap().get(actionMapKey);
            if (action != null) {
                action.actionPerformed(new ActionEvent(completionScrollPane, 0, null));
                evt.consume();
            }
        }
    }
}
项目:jvb    文件:DefaultSwingInputProvider.java   
@Override
public boolean postProcessKeyEvent(KeyEvent e) {
    Inputs input = keyCodeToInput(e.getKeyCode(), e.getKeyLocation());
    if (input == null) {
        return false;
    }
    if (e.getID() == KeyEvent.KEY_PRESSED) {
        status |= intBit(input.offset());
        return true;
    } else if (e.getID() == KeyEvent.KEY_RELEASED) {
        status &= ~intBit(input.offset());
        return true;
    }
    return false;
}
项目:ProyectoPacientes    文件:JDagregar.java   
private void direccionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_direccionKeyPressed
    // TODO add your handling code here:
    if(evt.getKeyCode() == KeyEvent.VK_ENTER)
    {
        this.telefono.requestFocus();
    }
}
项目:jdk8u-jdk    文件:WToolkit.java   
@Override
public boolean getLockingKeyState(int key) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
    return getLockingKeyStateNative(key);
}
项目:jdk8u-jdk    文件:bug8032878.java   
private void runTest() throws Exception {
    realSync();
    // Select 'one'
    Util.hitKeys(robot, KeyEvent.VK_TAB);
    realSync();
    Util.hitKeys(robot, KeyEvent.VK_1);
    Util.hitKeys(robot, KeyEvent.VK_2);
    Util.hitKeys(robot, KeyEvent.VK_3);
    Util.hitKeys(robot, KeyEvent.VK_ENTER);
    realSync();
}
项目:jdk8u-jdk    文件:WTextFieldPeer.java   
@Override
public boolean handleJavaKeyEvent(KeyEvent e) {
    switch (e.getID()) {
       case KeyEvent.KEY_TYPED:
           if ((e.getKeyChar() == '\n') && !e.isAltDown() && !e.isControlDown()) {
                postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
                                          getText(), e.getWhen(), e.getModifiers()));
                return true;
           }
       break;
    }
    return false;
}
项目:openjdk-jdk10    文件:MouseComboBoxTest.java   
public static void main(String[] args) throws Exception {
    robot = new Robot();
    robot.setAutoDelay(50);

    UIManager.setLookAndFeel(new MetalLookAndFeel());
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            createAndShowGUI();
        }
    });
    robot.waitForIdle();

    for (int i = 0; i < items.length; i++) {
        // Open popup
        robot.keyPress(KeyEvent.VK_DOWN);
        robot.keyRelease(KeyEvent.VK_DOWN);
        robot.waitForIdle();

        Point point = getItemPointToClick(i);
        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        robot.waitForIdle();

        if (i != getSelectedIndex()) {
            throw new RuntimeException("Test Failed! Incorrect value of selected index = " + getSelectedIndex() +
                    ", expected value = " + i);
        }
    }
}
项目:Pixie    文件:UserConfigs.java   
/**
 * Handles the keys which have to be enabled all the time in the frame.
 */
private void dispatchKeyGeneral(KeyEvent e) {
    int eventId = e.getID();
    int key = e.getKeyCode();

    if (eventId == KeyEvent.KEY_PRESSED) {

        switch (key) {

            case KeyEvent.VK_ESCAPE:
                cancelWindow();
                break;

            case KeyEvent.VK_ENTER:
                // if the textfield id the focus owner, do not save the object
                if (jFTFObjAlphaVal.isFocusOwner() || jFTFDPIValue.isFocusOwner()) {
                    break;
                }

                savePreferences();
                break;

            default:
                // do nothing
                break;
        }
    }
}
项目:OpenDA    文件:PlotBox.java   
public void keyReleased(KeyEvent e) {
    int keycode = e.getKeyCode();
    switch(keycode) {
    case KeyEvent.VK_CONTROL:
        _control = false;
        break;
    case KeyEvent.VK_SHIFT:
        _shift = false;
        break;
    default:
        // None
    }
}