当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.consume方法代码示例

本文整理汇总了Java中java.awt.event.KeyEvent.consume方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.consume方法的具体用法?Java KeyEvent.consume怎么用?Java KeyEvent.consume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.event.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.consume方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(Canvas canvas, KeyEvent e) {
	if (state == MOVING && e.getKeyCode() == KeyEvent.VK_SHIFT) {
		handleMoveDrag(canvas, curDx, curDy, e.getModifiersEx());
	} else {
		switch (e.getKeyCode()) {
		case KeyEvent.VK_BACK_SPACE:
		case KeyEvent.VK_DELETE:
			if (!canvas.getSelection().isEmpty()) {
				Action act = SelectionActions.clear(canvas.getSelection());
				canvas.getProject().doAction(act);
				e.consume();
			}
			break;
		default:
			processKeyEvent(canvas, e, KeyConfigurationEvent.KEY_PRESSED);
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:SelectTool.java

示例2: processKeyEvent

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
protected void processKeyEvent(KeyEvent e) {
    KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e);
    if (enter.equals(ks)) {
        // Prevent JComponent.processKeyBindings() to be called (it is called from
        // JComponent.processKeyEvent() ), notify only registered key listeners
        int id = e.getID();
        for (KeyListener keyListener : getKeyListeners()) {
            switch(id) {
              case KeyEvent.KEY_TYPED:
                  keyListener.keyTyped(e);
                  break;
              case KeyEvent.KEY_PRESSED:
                  keyListener.keyPressed(e);
                  break;
              case KeyEvent.KEY_RELEASED:
                  keyListener.keyReleased(e);
                  break;
            }
        }
        if (!e.isConsumed() && id == KeyEvent.KEY_PRESSED) {
            synchronized(listeners) {
                List<CellEditorListener> list = new ArrayList<CellEditorListener>(listeners);
                for (CellEditorListener listener : list) {
                    listener.editingStopped(new ChangeEvent(this));
                }
            }
        }
        e.consume();
    } else {
        super.processKeyEvent(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:WatchesColumnModels.java

示例3: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CheckListener.java

示例4: keyTyped

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyTyped(KeyEvent k) {

        if (k.getKeyChar() == '\n' && k.isControlDown()) {
            k.consume();
            executeCurrentSQL();
        }
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:8,代码来源:DatabaseManagerSwing.java

示例5: keyReleased

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyReleased(KeyEvent ke) {
    if(letTextPaneHandleKey(ke)) {
        return;
    }  else if(sc) {
        sc = false;
    } else if(ke.getKeyCode() == KeyEvent.VK_DELETE) {
        codeInputHandler.delete();
    } else {
        codeInputHandler.handleSpecialKey(ke);
    }
    ke.consume();
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:14,代码来源:UserInputHandler.java

示例6: keyReleased

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
/**
 * the key released event
 * @param event 
 */
@Override
public void keyReleased(KeyEvent event)
{
    if(event.getModifiers() != SHORTCUT_MASK && !(isDeadKey(event) && isActive) )
    {
        event.consume();
    }
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:13,代码来源:Console.java

示例7: keyTyped

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyTyped(KeyEvent e) {
    key = e.getKeyChar();
    if (key == (char) 127 || key == '\b' || key == '\n') {
        e.consume();
        return;
    }

    if (e.getModifiers() == KeyEvent.CTRL_MASK) {
        return;
    }

    palavra = insertChar(palavra, key);
    posCursor++;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:16,代码来源:MasterCli.java

示例8: processKeyEvent

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void processKeyEvent(KeyEvent ke) {
    //override the default handling so that
    //the parent will never receive the escape key and
    //close a modal dialog
    if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
        removeSearchField();
        ke.consume();
    } else {
        super.processKeyEvent(ke);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:PalettePanel.java

示例9: keyReleased

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyReleased(KeyEvent event) {
    super.keyPressed(event);
    if (!event.isConsumed() && event.getSource() == criteria.getSearchTextField() && event.getKeyChar() == KeyEvent.VK_ENTER) {
        event.consume();
        refreshData();
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:9,代码来源:SynsetViewUI.java

示例10: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent evt) {
    if (evt.getModifiers() == 0 && evt.getKeyCode() == KeyEvent.VK_ENTER) {
        evt.consume();
        btnSignIn.doClick();
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:8,代码来源:LoginWindow.java

示例11: altPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
void altPressed(KeyEvent ev) {
    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    MenuElement[] path = msm.getSelectedPath();
    if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
        msm.clearSelectedPath();
        menuCanceledOnPress = true;
        ev.consume();
    } else if(path.length > 0) { // We are in ComboBox
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        ev.consume();
    } else {
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        JMenuBar mbar = root != null ? root.getJMenuBar() : null;
        if(mbar == null && winAncestor instanceof JFrame) {
            mbar = ((JFrame)winAncestor).getJMenuBar();
        }
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;
        if(menu != null) {
            ev.consume();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:WindowsRootPaneUI.java

示例12: processKeyEvent

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
protected void processKeyEvent(KeyEvent event) {
    if (event.getID() == KeyEvent.KEY_RELEASED) {
        int row = getSelectedRow();
        
        if (row != -1) {
            if (event.getKeyCode() == KeyEvent.VK_LEFT) {
                if (treeRenderer.isExpanded(row)) {
                    treeRenderer.collapseRow(row);
                } else {
                    int parentRow = treeRenderer.getRowForPath(treeRenderer.getPathForRow(row).getParentPath());
                    
                    treeRenderer.collapseRow(parentRow);
                    getSelectionModel().setSelectionInterval(parentRow, parentRow);
                }
                event.consume();
                return;
            }
            if (event.getKeyCode() == KeyEvent.VK_RIGHT) {
                if (treeRenderer.isCollapsed(row)) {
                    treeRenderer.expandRow(row);
                }
                event.consume();
                return;
            }
        }
    }
    
    super.processKeyEvent(event);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:NbiTreeTable.java

示例13: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();
    if (keyCode == KeyEvent.VK_ESCAPE) {
        removeSearchField();
        ETable.this.requestFocus();
    } else if (keyCode == KeyEvent.VK_UP) {
        currentSelectionIndex--;
        displaySearchResult();
        // Stop processing the event here. Otherwise it's dispatched
        // to the table too (which scrolls)
        e.consume();
    } else if (keyCode == KeyEvent.VK_DOWN) {
        currentSelectionIndex++;
        displaySearchResult();
        // Stop processing the event here. Otherwise it's dispatched
        // to the table too (which scrolls)
        e.consume();
    } else if (keyCode == KeyEvent.VK_TAB) {
        if (maxPrefix != null) {
            searchTextField.setText(maxPrefix);
        }
        e.consume();
    } else if (keyCode == KeyEvent.VK_ENTER) {
        removeSearchField();
        
        // TODO: do something on hitting enter???
        e.consume();
        ETable.this.requestFocus();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ETable.java

示例14: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyChar() == ' ') {
        JTree tree = (JTree) e.getSource();
        TreePath path = tree.getSelectionPath();
        if (path != null) {
            CheckNode node = (CheckNode) path.getLastPathComponent();
            node.setSelected(!node.isSelected());
            tree.repaint();
            e.consume();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CheckNodeListener.java

示例15: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();
    if (keyCode == KeyEvent.VK_SPACE) {
        JTree tree = (JTree) e.getSource();
        TreePath path = tree.getSelectionPath();
        if (path != null) {
            FileNode node = (FileNode) path.getLastPathComponent();
            node.setSelected(!node.isSelected());
            tree.repaint();
            e.consume();
        }
    } 
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:RevertDeletedAction.java


注:本文中的java.awt.event.KeyEvent.consume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。