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

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

源代码1 项目: plugins   文件: KeyRemappingConfig.java
@ConfigItem(
	position = 3,
	keyName = "down",
	name = "Camera Down key",
	description = "The key which will replace down."
)
default ModifierlessKeybind down()
{
	return new ModifierlessKeybind(KeyEvent.VK_S, 0);
}
 
/**
 * Respond to a key press event on the graph. This will respond to keys that
 * interact directly with the graph's visuals, such as W,A,S,D to pan. Most
 * key presses in CONSTELLATION, for example Ctrl+A, will be picked up by
 * the netbeans framework and cause plugins to be executed.
 * <p>
 * This is called continually whenever a key is held down (at the key repeat
 * rate of the operating system).
 *
 * @param event The KeyEvent related to the key press.
 */
@Override
public void keyPressed(final KeyEvent event) {
    final int keyCode = event.getKeyCode();
    // Avoid the control key so we don't interfere with ^S for save, for example.
    final boolean isCtrl = event.isControlDown();
    final boolean isShift = event.isShiftDown();
    if (keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_PAGE_DOWN || (!isCtrl
            && (keyCode == KeyEvent.VK_A || keyCode == KeyEvent.VK_D || keyCode == KeyEvent.VK_S || keyCode == KeyEvent.VK_W))) {
        queue.add(wg -> {
            if (wg != null) {
                final Camera camera = new Camera(VisualGraphUtilities.getCamera(wg));
                if (keyCode == KeyEvent.VK_PAGE_UP) {
                    CameraUtilities.changeMixRatio(camera, true, isCtrl);
                    eventState.addEventName(MIX_ACTION_NAME);
                } else if (keyCode == KeyEvent.VK_PAGE_DOWN) {
                    CameraUtilities.changeMixRatio(camera, false, isCtrl);
                    eventState.addEventName(MIX_ACTION_NAME);
                } else if (keyCode == KeyEvent.VK_A) {
                    CameraUtilities.pan(camera, -0.5f * (isShift ? 10 : 1), 0);
                    eventState.addEventName(PAN_ACTION_NAME);
                } else if (keyCode == KeyEvent.VK_D) {
                    CameraUtilities.pan(camera, 0.5f * (isShift ? 10 : 1), 0);
                    eventState.addEventName(PAN_ACTION_NAME);
                } else if (keyCode == KeyEvent.VK_S) {
                    CameraUtilities.pan(camera, 0, -0.5f * (isShift ? 10 : 1));
                    eventState.addEventName(PAN_ACTION_NAME);
                } else if (keyCode == KeyEvent.VK_W) {
                    CameraUtilities.pan(camera, 0, 0.5f * (isShift ? 10 : 1));
                    eventState.addEventName(PAN_ACTION_NAME);
                }
                VisualGraphUtilities.setCamera(wg, camera);
                scheduleCameraChangeOperation();
            }
            return STANDARD_DELAY;
        });
    }
}
 
源代码3 项目: TrakEM2   文件: DNDTree.java
public void keyPressed(final KeyEvent ke) {
	if (!ke.getSource().equals(DNDTree.this) || !project.isInputEnabled()) {
		ke.consume();
		return;
	}
	int key_code = ke.getKeyCode();
	switch (key_code) {
		case KeyEvent.VK_S:
			project.getLoader().saveTask(project, "Save");
			ke.consume();
			break;
	}
}
 
public void tick(){
	up = keys[KeyEvent.VK_W];
	down = keys[KeyEvent.VK_S];
	left = keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_D];
	
	aUp = keys[KeyEvent.VK_UP];
	aDown = keys[KeyEvent.VK_DOWN];
	aLeft = keys[KeyEvent.VK_LEFT];
	aRight = keys[KeyEvent.VK_RIGHT];
}
 
源代码5 项目: runelite   文件: KeyRemappingConfig.java
@ConfigItem(
	position = 3,
	keyName = "down",
	name = "Camera Down key",
	description = "The key which will replace down.",
	section = cameraSection
)
default ModifierlessKeybind down()
{
	return new ModifierlessKeybind(KeyEvent.VK_S, 0);
}
 
源代码6 项目: open-ig   文件: AnimPlayList.java
/**
 * Action on key typed within the table.
 * @param e the keyboard event
 */
protected void doKeyTyped(KeyEvent e) {
	if (e.getKeyCode() == KeyEvent.VK_SPACE || e.getKeyCode() == KeyEvent.VK_ENTER) {
		doPlaySelected();
		e.consume();
	} else
	if (e.getKeyCode() == KeyEvent.VK_S) {
		AnimPlay.menuStop.doClick();
	} else
	if (e.getKeyCode() == KeyEvent.VK_D) {
		AnimPlay.menuReplay.doClick();
	}
}
 
源代码7 项目: JavaGame   文件: MenuInput.java
private void toggleKey(int keyCode) {

		if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_W) {
			Menu.setSelectedStart(true);
			Menu.setSelectedExit(false);
		}

		if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_S) {
			Menu.setSelectedExit(true);
			Menu.setSelectedStart(false);
		}

		if(!ticket){
			if (keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_SPACE) {
				if (Menu.isSelectedStart()) {
					this.ticket = true;
					Menu.setRunning(false);
					Menu.getFrame().setVisible(false);
					Menu.getFrame().stopFrame();
					new Game().start();
				}

				if (Menu.isSelectedExit()) {
					this.ticket = true;
					Menu.setRunning(false);
					Menu.getFrame().setVisible(false);
					Menu.getFrame().stopFrame();
				}
			}
		}

		if (keyCode == KeyEvent.VK_ESCAPE) {
			System.exit(1);
		}

		if (keyCode == KeyEvent.VK_H){
			HelpMenu h = new HelpMenu();
			if (!help)
				h.run();
			help = true;
		}
	}
 
public void tick(){
	up = keys[KeyEvent.VK_W];
	down = keys[KeyEvent.VK_S];
	left = keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_D];
}
 
源代码9 项目: workcraft   文件: SelectionTool.java
@Override
public int getHotKeyCode() {
    return KeyEvent.VK_S;
}
 
源代码10 项目: hottub   文件: EditorTopComponent.java
public void keyReleased(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_S) {
        EditorTopComponent.this.overviewButton.setSelected(false);
        EditorTopComponent.this.overviewAction.setState(false);
    }
}
 
private static boolean isSave(KeyEvent ke) {
    return (ke.isMetaDown() || ke.isControlDown()) && ke.getKeyCode() == KeyEvent.VK_S;
}
 
public void tick(){
	up = keys[KeyEvent.VK_W];
	down = keys[KeyEvent.VK_S];
	left = keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_D];
}
 
public void tick(){
	up = keys[KeyEvent.VK_W];
	down = keys[KeyEvent.VK_S];
	left = keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_D];
}
 
源代码14 项目: PIPE   文件: SelectAction.java
public SelectAction(PipeApplicationModel applicationModel, PipeApplicationView pipeApplicationView,
                    PipeApplicationController pipeApplicationController) {
    super("Select", "Select components (alt-S)", KeyEvent.VK_S, InputEvent.ALT_DOWN_MASK, applicationModel);
    this.pipeApplicationView = pipeApplicationView;
    this.pipeApplicationController = pipeApplicationController;
}
 
源代码15 项目: OpenDA   文件: PlotFrame.java
/** Construct a plot frame with the specified title and the specified
 *  instance of PlotBox.  After constructing this, it is necessary
 *  to call setVisible(true) to make the plot appear.
 *  @param title The title to put on the window.
 *  @param plotArg the plot object to put in the frame, or null to create
 *   an instance of Plot.
 */
public PlotFrame(String title, PlotBox plotArg) {
    super(title);

    if (plotArg == null) {
        plot = new Plot();
    } else {
        plot = plotArg;
    }

    // Background color is a light grey.
    plot.setBackground(new Color(0xe5e5e5));

    _fileMenu.setMnemonic(KeyEvent.VK_F);
    _editMenu.setMnemonic(KeyEvent.VK_E);
    _specialMenu.setMnemonic(KeyEvent.VK_S);

    // File menu
    JMenuItem[] fileMenuItems = {
        new JMenuItem("Open", KeyEvent.VK_O),
        new JMenuItem("Save", KeyEvent.VK_S),
        new JMenuItem("Save as....", KeyEvent.VK_A),
        new JMenuItem("Export", KeyEvent.VK_E),
        new JMenuItem("Print", KeyEvent.VK_P),
        new JMenuItem("Close", KeyEvent.VK_C),
    };
    // Open button = ctrl-o.
    fileMenuItems[0].setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK));

    // Save button = ctrl-s.
    fileMenuItems[1].setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));

    // Print button = ctrl-p.
    fileMenuItems[4].setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK));

    // Close button = ctrl-w.
    fileMenuItems[5].setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, Event.CTRL_MASK));

    FileMenuListener fml = new FileMenuListener();
    // Set the action command and listener for each menu item.
    for (int i = 0; i < fileMenuItems.length; i++) {
        fileMenuItems[i].setActionCommand(fileMenuItems[i].getText());
        fileMenuItems[i].addActionListener(fml);
        _fileMenu.add(fileMenuItems[i]);
    }
    _menubar.add(_fileMenu);

    // Edit menu
    JMenuItem format = new JMenuItem("Format", KeyEvent.VK_F);
    FormatListener formatListener = new FormatListener();
    format.addActionListener(formatListener);
    _editMenu.add(format);
    _menubar.add(_editMenu);

    // Special menu
    JMenuItem[] specialMenuItems = {
        new JMenuItem("About", KeyEvent.VK_A),
        new JMenuItem("Help", KeyEvent.VK_H),
        new JMenuItem("Clear", KeyEvent.VK_C),
        new JMenuItem("Fill", KeyEvent.VK_F),
        new JMenuItem("Reset axes", KeyEvent.VK_R),
        new JMenuItem("Sample plot", KeyEvent.VK_S),
    };
    SpecialMenuListener sml = new SpecialMenuListener();
    // Set the action command and listener for each menu item.
    for (int i = 0; i < specialMenuItems.length; i++) {
        specialMenuItems[i].setActionCommand(
                specialMenuItems[i].getText());
        specialMenuItems[i].addActionListener(sml);
        _specialMenu.add(specialMenuItems[i]);
    }
    _menubar.add(_specialMenu);

    setJMenuBar(_menubar);

    getContentPane().add(plot, BorderLayout.CENTER);
    // FIXME: This should not be hardwired in here.
    setSize(500, 300);

    // Center.
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = getSize();
    int x = (screenSize.width - frameSize.width) / 2;
    int y = (screenSize.height - frameSize.height) / 2;
    setLocation(x, y);
}
 
源代码16 项目: openjdk-8-source   文件: EditorTopComponent.java
public void keyReleased(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_S) {
        EditorTopComponent.this.overviewButton.setSelected(false);
        EditorTopComponent.this.overviewAction.setState(false);
    }
}
 
源代码17 项目: opt4j   文件: PlotFrame.java
/**
 * Construct a plot frame with the specified title and the specified
 * instance of PlotBox. After constructing this, it is necessary to call
 * setVisible(true) to make the plot appear.
 * 
 * @param title
 *            The title to put on the window.
 * @param plotArg
 *            the plot object to put in the frame, or null to create an
 *            instance of Plot.
 */
public PlotFrame(String title, PlotBox plotArg) {
	super(title);

	// The Java look & feel is pretty lame, so we use the native
	// look and feel of the platform we are running on.
	try {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	} catch (Exception e) {
		// Ignore exceptions, which only result in the wrong look and feel.
	}

	if (plotArg == null) {
		plot = new Plot();
	} else {
		plot = plotArg;
	}

	// Background color is a light grey.
	plot.setBackground(new Color(0xe5e5e5));

	_fileMenu.setMnemonic(KeyEvent.VK_F);
	_editMenu.setMnemonic(KeyEvent.VK_E);
	_specialMenu.setMnemonic(KeyEvent.VK_S);

	// File menu
	JMenuItem[] fileMenuItems = { new JMenuItem("Open", KeyEvent.VK_O), new JMenuItem("Save", KeyEvent.VK_S),
			new JMenuItem("SaveAs", KeyEvent.VK_A), new JMenuItem("Export", KeyEvent.VK_E),
			new JMenuItem("Print", KeyEvent.VK_P), new JMenuItem("Close", KeyEvent.VK_C), };

	// Open button = ctrl-o.
	fileMenuItems[0].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK));

	// Save button = ctrl-s.
	fileMenuItems[1].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));

	// Print button = ctrl-p.
	fileMenuItems[4].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK));

	// Close button = ctrl-w.
	fileMenuItems[5].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, Event.CTRL_MASK));

	FileMenuListener fml = new FileMenuListener();

	// Set the action command and listener for each menu item.
	for (int i = 0; i < fileMenuItems.length; i++) {
		fileMenuItems[i].setActionCommand(fileMenuItems[i].getText());
		fileMenuItems[i].addActionListener(fml);
		_fileMenu.add(fileMenuItems[i]);
	}

	_menubar.add(_fileMenu);

	// Edit menu
	JMenuItem format = new JMenuItem("Format", KeyEvent.VK_F);
	FormatListener formatListener = new FormatListener();
	format.addActionListener(formatListener);
	_editMenu.add(format);
	_menubar.add(_editMenu);

	// Special menu
	JMenuItem[] specialMenuItems = { new JMenuItem("About", KeyEvent.VK_A), new JMenuItem("Help", KeyEvent.VK_H),
			new JMenuItem("Clear", KeyEvent.VK_C), new JMenuItem("Fill", KeyEvent.VK_F),
			new JMenuItem("Reset axes", KeyEvent.VK_R), new JMenuItem("Sample plot", KeyEvent.VK_S), };
	SpecialMenuListener sml = new SpecialMenuListener();

	// Set the action command and listener for each menu item.
	for (int i = 0; i < specialMenuItems.length; i++) {
		specialMenuItems[i].setActionCommand(specialMenuItems[i].getText());
		specialMenuItems[i].addActionListener(sml);
		_specialMenu.add(specialMenuItems[i]);
	}

	_menubar.add(_specialMenu);

	setJMenuBar(_menubar);

	getContentPane().add(plot, BorderLayout.CENTER);

	// FIXME: This should not be hardwired in here.
	setSize(500, 300);

	// Center.
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	Dimension frameSize = getSize();
	int x = (screenSize.width - frameSize.width) / 2;
	int y = (screenSize.height - frameSize.height) / 2;
	setLocation(x, y);
}
 
源代码18 项目: openjdk-jdk8u   文件: EditorTopComponent.java
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_S) {
        EditorTopComponent.this.overviewButton.setSelected(true);
        EditorTopComponent.this.overviewAction.setState(true);
    }
}
 
源代码19 项目: 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 "";
	}
}
 
public void tick(){
	up = keys[KeyEvent.VK_W];
	down = keys[KeyEvent.VK_S];
	left = keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_D];
}