VK_V源码实例Demo

java.awt.event.KeyEvent#VK_V源码实例Demo

下面列出了java.awt.event.KeyEvent#VK_V 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openAGV   文件: OpenTCSDrawingView.java
@Override
public void processKeyEvent(KeyEvent e) {
  if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
    // Cut, copy, paste and duplicate
    if (e.getKeyCode() == KeyEvent.VK_X
        || e.getKeyCode() == KeyEvent.VK_C
        || e.getKeyCode() == KeyEvent.VK_V
        || e.getKeyCode() == KeyEvent.VK_D) {
      if (!appState.hasOperationMode(OperationMode.MODELLING)) {
        return;
      }
      processCutPasteKeyEvent();
    }
  }

  super.processKeyEvent(e);
}
 
源代码2 项目: ghidra   文件: KeyBindingUtilsTest.java
@Test
public void testParseKeyStroke() {

	KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_V, 0);
	String parsed = KeyBindingUtils.parseKeyStroke(ks);
	assertEquals("V", parsed);

	ks = KeyStroke.getKeyStroke('v');
	parsed = KeyBindingUtils.parseKeyStroke(ks);
	assertEquals("v", parsed);

	int modifiers = InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK;
	ks = KeyStroke.getKeyStroke(KeyEvent.VK_V, modifiers);
	parsed = KeyBindingUtils.parseKeyStroke(ks);
	assertEquals("Ctrl-Shift-V", parsed);

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_V, modifiers, true);
	parsed = KeyBindingUtils.parseKeyStroke(ks);
	assertEquals("Ctrl-Shift-V", parsed);

	JButton b = new JButton();
	KeyEvent event = new KeyEvent(b, KeyEvent.KEY_PRESSED, 1, modifiers, KeyEvent.VK_V, 'v');
	ks = KeyStroke.getKeyStrokeForEvent(event);
	parsed = KeyBindingUtils.parseKeyStroke(ks);
	assertEquals("Ctrl-Shift-V", parsed);
}
 
@Override
public void keyReleased(KeyEvent event) {
    if (event.isControlDown() || event.isMetaDown()) {
        switch (event.getKeyCode()) {
            case KeyEvent.VK_C:
                // Copy
                cancelEditing();
                XTableUtils.copyToClipboard(table, false);
                break;
            case KeyEvent.VK_X:
                // Cut
                cancelEditing();
                XTableUtils.copyToClipboard(table, true);
                break;
            case KeyEvent.VK_V:
                // Paste
                cancelEditing();
                XTableUtils.pasteFromClipboard(table);
                break;
            default:
                break;
        }
    }

}
 
源代码4 项目: brModelo   文件: MasterCli.java
public boolean processeAtalhos(int keyCode) {
    boolean res = false;
    switch (keyCode) {
        case KeyEvent.VK_V:
            doPaste();
            res = true;
            break;
        case KeyEvent.VK_Q:
            Sair();
            res = true;
            break;
        case KeyEvent.VK_D:
            Cancelar();
            res = true;
            break;
    }
    return res;
}
 
源代码5 项目: wpcleaner   文件: Utilities.java
/**
 * Listener for KeyPressed events.
 * 
 * @param e Event.
 * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
 */
@Override
public void keyPressed(KeyEvent e) {
  if ((e.getKeyCode() == KeyEvent.VK_V) &&
      ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0)) {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    Transferable clipData = clipboard.getContents(clipboard);
    try {
      String s = (String) clipData.getTransferData(DataFlavor.stringFlavor);
      int start = text.getSelectionStart();
      int end = text.getSelectionEnd();
      if (end > start) {
        text.getDocument().remove(start, end - start);
      }
      text.getDocument().insertString(start, s, null);
      e.consume();
    } catch (Exception ex) {
      //
    }
  }
}
 
源代码6 项目: Bytecoder   文件: SwingUtilities2.java
/**
 * Returns true if the given event is corrent gesture for
 * accessing clipboard
 *
 * @param ie InputEvent to check
 */
@SuppressWarnings("deprecation")
private static boolean isAccessClipboardGesture(InputEvent ie) {
    boolean allowedGesture = false;
    if (ie instanceof KeyEvent) { //we can validate only keyboard gestures
        KeyEvent ke = (KeyEvent)ie;
        int keyCode = ke.getKeyCode();
        int keyModifiers = ke.getModifiers();
        switch(keyCode) {
        case KeyEvent.VK_C:
        case KeyEvent.VK_V:
        case KeyEvent.VK_X:
            allowedGesture = (keyModifiers == InputEvent.CTRL_MASK);
            break;
        case KeyEvent.VK_INSERT:
            allowedGesture = (keyModifiers == InputEvent.CTRL_MASK ||
                              keyModifiers == InputEvent.SHIFT_MASK);
            break;
        case KeyEvent.VK_COPY:
        case KeyEvent.VK_PASTE:
        case KeyEvent.VK_CUT:
            allowedGesture = true;
            break;
        case KeyEvent.VK_DELETE:
            allowedGesture = ( keyModifiers == InputEvent.SHIFT_MASK);
            break;
        }
    }
    return allowedGesture;
}
 
/**
 * Performs certain actions for certain keys:
 * <ul>
 *     <li>Escape: close application</li>
 *     <li>V and B: cancel rotation</li>
 *     <li>N: clear rotation</li>
 * </ul>
 * @param e The key event
 */
@Override
public void keyReleased(KeyEvent e) {
    if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
        //Close application on escape
        Utilities.closeApplication(frame);
    } else if (KeyEvent.VK_V == e.getKeyCode() || KeyEvent.VK_B == e.getKeyCode()) {
        //Cancel rotation
        rotateTimer.stop();
    } else if (KeyEvent.VK_N == e.getKeyCode()) {
        mapController.setRotation(0);
        mapController.getLocationController().setNavigationMode(NavigationMode.NORTH_UP);
    }
}
 
源代码8 项目: Spark   文件: ChatRoomTransferDecorator.java
@Override
public void keyPressed(KeyEvent ke) {
       if (ke.getKeyCode() == KeyEvent.VK_V) {
           int i = ke.getModifiers();
           if ((i & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) {
               Clipboard clb = Toolkit.getDefaultToolkit().getSystemClipboard();
               Transferable contents = clb.getContents(ke.getSource());
               if (contents != null && contents.getTransferDataFlavors().length == 1) {
                   if (contents.isDataFlavorSupported(DataFlavor.imageFlavor)) {
                       SparkManager.getTransferManager().sendImage(SparkTransferManager.getClipboard(), chatRoom);
                   }
               }
           }
       }
   }
 
源代码9 项目: jaamsim   文件: ObjectSelector.java
@Override
public void keyPressed(KeyEvent e) {
	int keyCode = e.getKeyCode();
	boolean control = e.isControlDown();
	if (control && keyCode == KeyEvent.VK_C) {
		if (currentEntity != null) {
			GUIFrame.getInstance().copyToClipboard(currentEntity);
		}
	}
	if (control && keyCode == KeyEvent.VK_V) {
		GUIFrame.getInstance().pasteEntityFromClipboard();
	}
}
 
源代码10 项目: hortonmachine   文件: TableListener.java
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
        pressed = true;
    }
    if (pressed && e.getKeyCode() == KeyEvent.VK_V) {
        adaptee.pasteClipboard();
    }
}
 
源代码11 项目: haxademic   文件: RobotKeyPressMidi.java
protected void firstFrame() {
	MidiDevice.init(0, 0);
	try { _robot = new Robot(); } catch( Exception error ) { println("couldn't init Robot"); }
	
	midiKeyTriggers = new MidiKeyTrigger[] {
			new MidiKeyTrigger(39, KeyEvent.VK_V),
			new MidiKeyTrigger(40, KeyEvent.VK_A),
			new MidiKeyTrigger(54, KeyEvent.VK_B),
			new MidiKeyTrigger(65, KeyEvent.VK_L)
	};
}
 
源代码12 项目: plugins   文件: LoginScreenPlugin.java
@Override
public void keyPressed(KeyEvent e)
{
	if (!config.pasteEnabled() || (
		client.getGameState() != GameState.LOGIN_SCREEN &&
			client.getGameState() != GameState.LOGIN_SCREEN_AUTHENTICATOR))
	{
		return;
	}

	// enable pasting on macOS with the Command (meta) key
	boolean isModifierDown = OSType.getOSType() == OSType.MacOS ? e.isMetaDown() : e.isControlDown();

	if (e.getKeyCode() == KeyEvent.VK_V && isModifierDown)
	{
		try
		{
			final String data = Toolkit
				.getDefaultToolkit()
				.getSystemClipboard()
				.getData(DataFlavor.stringFlavor)
				.toString()
				.trim();

			switch (client.getLoginIndex())
			{
				// Username/password form
				case 2:
					if (client.getCurrentLoginField() == 0)
					{
						// Truncate data to maximum username length if necessary
						client.setUsername(data.substring(0, Math.min(data.length(), MAX_USERNAME_LENGTH)));
					}

					break;
				// Authenticator form
				case 4:
					// Truncate data to maximum OTP code length if necessary
					client.setOtp(data.substring(0, Math.min(data.length(), MAX_PIN_LENGTH)));
					break;
			}
		}
		catch (UnsupportedFlavorException | IOException ex)
		{
			log.warn("failed to fetch clipboard data", ex);
		}
	}
}
 
源代码13 项目: workcraft   文件: SelectionTool.java
@Override
public boolean keyPressed(GraphEditorKeyEvent e) {
    GraphEditor editor = e.getEditor();
    switch (e.getKeyCode()) {
    case KeyEvent.VK_ESCAPE:
        if (isDragging()) {
            cancelDrag(editor);
        } else {
            cancelSelection(editor);
        }
        return true;
    case KeyEvent.VK_PAGE_UP:
        changeLevelUp(editor);
        return true;
    case KeyEvent.VK_PAGE_DOWN:
        changeLevelDown(editor);
        return true;
    }

    if (!e.isMenuKeyDown() && !e.isShiftKeyDown()) {
        switch (e.getKeyCode()) {
        case KeyEvent.VK_LEFT:
            offsetSelection(editor, -1, 0);
            return true;
        case KeyEvent.VK_RIGHT:
            offsetSelection(editor, 1, 0);
            return true;
        case KeyEvent.VK_UP:
            offsetSelection(editor, 0, -1);
            return true;
        case KeyEvent.VK_DOWN:
            offsetSelection(editor, 0, 1);
            return true;
        }
    }

    if (enablePaging && e.isAltKeyDown() && !e.isMenuKeyDown()) {
        switch (e.getKeyCode()) {
        case KeyEvent.VK_G:
            if (e.isShiftKeyDown()) {
                ungroupSelection(editor);
            } else {
                pageSelection(editor);
            }
            return true;
        }
    }

    if (enableGroupping && e.isMenuKeyDown() && !e.isAltKeyDown()) {
        switch (e.getKeyCode()) {
        case KeyEvent.VK_G:
            if (e.isShiftKeyDown()) {
                ungroupSelection(editor);
            } else {
                groupSelection(editor);
            }
            return true;
        }
    }

    if (e.isMenuKeyDown() && !e.isAltKeyDown()) {
        switch (e.getKeyCode()) {
        case KeyEvent.VK_V:
            Point2D pastePosition = TransformHelper.snapP5(currentMousePosition);
            editor.getWorkspaceEntry().setPastePosition(pastePosition);
            return true;
        }
    }

    if (e.isExtendKeyDown()) {
        currentNodes = getNodeWithAdjacentConnections(e.getModel(), currentNode);
        editor.repaint();
        return true;
    }

    return super.keyPressed(e);
}
 
源代码14 项目: xnx3   文件: Robot.java
/**
 * 将字符型转换为按键码,可直接使用 {@link #press(int)}调用
 * @param key 字符型文字,包含 0~9 a~z .
 * @return 按键码
 */
public int StringToKey(String key){
	switch (key) {
	case "a":
		return KeyEvent.VK_A;
	case "b":
		return KeyEvent.VK_B;
	case "c":
		return KeyEvent.VK_C;
	case "d":
		return KeyEvent.VK_D;
	case "e":
		return KeyEvent.VK_E;
	case "f":
		return KeyEvent.VK_F;
	case "g":
		return KeyEvent.VK_G;
	case "h":
		return KeyEvent.VK_H;
	case "i":
		return KeyEvent.VK_I;
	case "j":
		return KeyEvent.VK_J;
	case "k":
		return KeyEvent.VK_K;
	case "l":
		return KeyEvent.VK_L;
	case "m":
		return KeyEvent.VK_M;
	case "n":
		return KeyEvent.VK_N;
	case "o":
		return KeyEvent.VK_O;
	case "p":
		return KeyEvent.VK_P;
	case "q":
		return KeyEvent.VK_Q;
	case "r":
		return KeyEvent.VK_R;
	case "s":
		return KeyEvent.VK_S;
	case "t":
		return KeyEvent.VK_T;
	case "u":
		return KeyEvent.VK_U;
	case "v":
		return KeyEvent.VK_V;
	case "w":
		return KeyEvent.VK_W;
	case "x":
		return KeyEvent.VK_X;
	case "y":
		return KeyEvent.VK_Y;
	case "z":
		return KeyEvent.VK_Z;
	case "0":
		return KeyEvent.VK_0;
	case "1":
		return KeyEvent.VK_1;
	case "2":
		return KeyEvent.VK_2;
	case "3":
		return KeyEvent.VK_3;
	case "4":
		return KeyEvent.VK_4;
	case "5":
		return KeyEvent.VK_5;
	case "6":
		return KeyEvent.VK_6;
	case "7":
		return KeyEvent.VK_7;
	case "8":
		return KeyEvent.VK_8;
	case "9":
		return KeyEvent.VK_9;
	case ".":
		return KeyEvent.VK_PERIOD;
	default:
		break;
	}
	
	return 0;
}
 
源代码15 项目: Repeat   文件: KeyCodeToChar.java
private static String getLowerCaseAlphaChar(int code) {
	switch (code) {
	case KeyEvent.VK_Q:
		return "q";
	case KeyEvent.VK_W:
		return "w";
	case KeyEvent.VK_E:
		return "e";
	case KeyEvent.VK_R:
		return "r";
	case KeyEvent.VK_T:
		return "t";
	case KeyEvent.VK_Y:
		return "y";
	case KeyEvent.VK_U:
		return "u";
	case KeyEvent.VK_I:
		return "i";
	case KeyEvent.VK_O:
		return "o";
	case KeyEvent.VK_P:
		return "p";
	case KeyEvent.VK_A:
		return "a";
	case KeyEvent.VK_S:
		return "s";
	case KeyEvent.VK_D:
		return "d";
	case KeyEvent.VK_F:
		return "f";
	case KeyEvent.VK_G:
		return "g";
	case KeyEvent.VK_H:
		return "h";
	case KeyEvent.VK_J:
		return "j";
	case KeyEvent.VK_K:
		return "k";
	case KeyEvent.VK_L:
		return "l";
	case KeyEvent.VK_Z:
		return "z";
	case KeyEvent.VK_X:
		return "x";
	case KeyEvent.VK_C:
		return "c";
	case KeyEvent.VK_V:
		return "v";
	case KeyEvent.VK_B:
		return "b";
	case KeyEvent.VK_N:
		return "n";
	case KeyEvent.VK_M:
		return "m";
	default:
		return "";
	}
}
 
源代码16 项目: Repeat   文件: KeyCodeToChar.java
private static String getUpperCaseAlphaChar(int code) {
	switch (code) {
	case KeyEvent.VK_Q:
		return "Q";
	case KeyEvent.VK_W:
		return "W";
	case KeyEvent.VK_E:
		return "E";
	case KeyEvent.VK_R:
		return "R";
	case KeyEvent.VK_T:
		return "T";
	case KeyEvent.VK_Y:
		return "Y";
	case KeyEvent.VK_U:
		return "U";
	case KeyEvent.VK_I:
		return "I";
	case KeyEvent.VK_O:
		return "O";
	case KeyEvent.VK_P:
		return "P";
	case KeyEvent.VK_A:
		return "A";
	case KeyEvent.VK_S:
		return "S";
	case KeyEvent.VK_D:
		return "D";
	case KeyEvent.VK_F:
		return "F";
	case KeyEvent.VK_G:
		return "G";
	case KeyEvent.VK_H:
		return "H";
	case KeyEvent.VK_J:
		return "J";
	case KeyEvent.VK_K:
		return "K";
	case KeyEvent.VK_L:
		return "L";
	case KeyEvent.VK_Z:
		return "Z";
	case KeyEvent.VK_X:
		return "X";
	case KeyEvent.VK_C:
		return "C";
	case KeyEvent.VK_V:
		return "V";
	case KeyEvent.VK_B:
		return "B";
	case KeyEvent.VK_N:
		return "N";
	case KeyEvent.VK_M:
		return "M";
	default:
		return "";
	}
}
 
源代码17 项目: runelite   文件: LoginScreenPlugin.java
@Override
public void keyPressed(KeyEvent e)
{
	if (!config.pasteEnabled() || (
		client.getGameState() != GameState.LOGIN_SCREEN &&
		client.getGameState() != GameState.LOGIN_SCREEN_AUTHENTICATOR))
	{
		return;
	}

	// enable pasting on macOS with the Command (meta) key
	boolean isModifierDown = OSType.getOSType() == OSType.MacOS ? e.isMetaDown() : e.isControlDown();

	if (e.getKeyCode() == KeyEvent.VK_V && isModifierDown)
	{
		try
		{
			final String data = Toolkit
				.getDefaultToolkit()
				.getSystemClipboard()
				.getData(DataFlavor.stringFlavor)
				.toString()
				.trim();

			switch (client.getLoginIndex())
			{
				// Username/password form
				case 2:
					if (client.getCurrentLoginField() == 0)
					{
						// Truncate data to maximum username length if necessary
						client.setUsername(data.substring(0, Math.min(data.length(), MAX_USERNAME_LENGTH)));
					}

					break;
				// Authenticator form
				case 4:
					// Truncate data to maximum OTP code length if necessary
					client.setOtp(data.substring(0, Math.min(data.length(), MAX_PIN_LENGTH)));
					break;
			}
		}
		catch (UnsupportedFlavorException | IOException ex)
		{
			log.warn("failed to fetch clipboard data", ex);
		}
	}
}
 
源代码18 项目: Briss-2.0   文件: MergedPanel.java
@Override
public void keyPressed(KeyEvent e) {
    switch (e.getKeyCode()) {
        case KeyEvent.VK_C:
            if (e.getModifiersEx() == Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()) {
                copyToClipBoard();
            }
            break;
        case KeyEvent.VK_V:
            if (e.getModifiersEx() == Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()) {
                pasteFromClipBoard();
            }
            break;
        case KeyEvent.VK_DELETE:
            deleteAllSelected();
            break;
        case KeyEvent.VK_LEFT:
        case KeyEvent.VK_RIGHT:
        case KeyEvent.VK_UP:
        case KeyEvent.VK_DOWN:
            int x = 0;
            int y = 0;
            switch (e.getKeyCode()) {
                case KeyEvent.VK_LEFT:
                    x = -1;
                    break;
                case KeyEvent.VK_RIGHT:
                    x = 1;
                    break;
                case KeyEvent.VK_UP:
                    y = -1;
                    break;
                case KeyEvent.VK_DOWN:
                    y = 1;
                    break;
            }
            if ((e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0) {
                x *= 10;
                y *= 10;
            }
            if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
                briss.resizeSelRects(x, y);
            } else {
                briss.moveSelectedRects(x, y);
            }
            break;
        default:
    }
}
 
源代码19 项目: TrakEM2   文件: AreaTree.java
@Override
public void keyPressed(final KeyEvent ke) {
	final int tool = ProjectToolbar.getToolId();
	try {
		if (ProjectToolbar.BRUSH == tool) {

			final Object origin = ke.getSource();
			if (! (origin instanceof DisplayCanvas)) {
				ke.consume();
				return;
			}
			final DisplayCanvas dc = (DisplayCanvas)origin;
			final Layer layer = dc.getDisplay().getLayer();

			final Collection<Node<Area>> nodes = node_layer_map.get(layer);
			if (null == nodes || nodes.isEmpty()) {
				return;
			}

			final Point p = dc.getCursorLoc(); // as offscreen coords
			int x = p.x;
			int y = p.y;
			if (!this.at.isIdentity()) {
				final Point2D.Double po = inverseTransformPoint(x, y);
				x = (int)po.x;
				y = (int)po.y;
			}

			final AreaNode nd = findEventReceiver(nodes, x, y, layer, dc.getMagnification(), ke);

			// Prepare for paste command:
			if (null != nd && null == nd.aw && ke.getKeyCode() == KeyEvent.VK_V) {
				nd.getData(); // creates an.aw
			}

			if (null != nd && null != nd.aw) {
				nd.aw.setSource(this);
				nd.aw.keyPressed(ke, dc, layer);
				nd.aw.setSource(null);
				if (ke.isConsumed()) {
					updateViewData(nd);
					return;
				}
			}
		}
	} finally {
		if (!ke.isConsumed()) {
			super.keyPressed(ke);
		}
	}
}
 
源代码20 项目: PIPE   文件: PasteAction.java
public PasteAction(PipeApplicationController applicationController) {
    super("Paste", "Paste (Ctrl-V)", KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    this.applicationController = applicationController;
}