Java Code Examples for java.awt.event.KeyEvent#VK_F2

The following examples show how to use java.awt.event.KeyEvent#VK_F2 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MovingArea.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
public void processKeyBinding(final int keyKode) {
    if (pressedPanel != null) {
        switch (keyKode) {
            case KeyEvent.VK_F2:
                renameObject();
                return;
            default:
                // p = false;
                break;
        }
        // if (p)
        // pressedPanel.onEndBoundsChange();
    }
    if (KeyEvent.VK_ESCAPE == keyKode) {
        if (getState() == END_POINT_ADDING) {
            setState(START_POINT_ADDING);
            if (panel != null)
                panel.getFramework().remove(CURRENT_MOVING_AREA);
            repaintAsync();
        } else if (getChangingState() == ARROW_CHANGING_STATE) {
            if (panel != null)
                panel.getFramework().remove(CURRENT_MOVING_AREA);
            cancelAdding();
        }
    }
}
 
Example 2
Source File: NamedSelectionTopComponent.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void keyPressed(final KeyEvent e) {
    // On enter, retrieve the selection:
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        retrieveSelection();
    } // On F2, rename the selection:
    else if (e.getKeyCode() == KeyEvent.VK_F2) {
        renameElement();
    }
}
 
Example 3
Source File: PerspectiveBookmarkTopComponent.java    From constellation with Apache License 2.0 5 votes vote down vote up
private void perspectivesListKeyPressed(java.awt.event.KeyEvent evt)//GEN-FIRST:event_perspectivesListKeyPressed
{//GEN-HEADEREND:event_perspectivesListKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        moveToPerspective();
        evt.consume();
    } else if (evt.getKeyCode() == KeyEvent.VK_F2) {
        renamePerspective();
        evt.consume();
    }
}
 
Example 4
Source File: KeyboardMenuNavigator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if(e.getKeyCode() == KeyEvent.VK_DOWN) {
        selectOffsetMenuItem(+1);
    }
    if(e.getKeyCode() == KeyEvent.VK_UP) {
        selectOffsetMenuItem(-1);
    }
    if(e.getKeyCode() == KeyEvent.VK_LEFT) {
        selectOffsetMenu(-1);
    }
    if(e.getKeyCode() == KeyEvent.VK_RIGHT) {
        selectOffsetMenu(+1);
    }
    
    if(e.getKeyCode() == KeyEvent.VK_SPACE) {
        startEditing();
    }
    // #116961: start inplace editing when F2 key is pressed on a menu
    if(e.getKeyCode() == KeyEvent.VK_F2) {
        startEditing();
    }
    //we aren't getting tabs for some reason
    if(e.getKeyCode() == KeyEvent.VK_A) {
        if(e.isShiftDown()) {
            selectNextMenuItem(-1);
        } else {
            selectNextMenuItem(+1);
        }
    }
}
 
Example 5
Source File: UI2.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private void featureListKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_featureListKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_F2) {
        if (featureList.getSelectedValue() != null) {
            uic.startEdit((Story) featureList.getSelectedValue());
        }
    }
}
 
Example 6
Source File: Window.java    From Snake with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent keyEvent) {

    if (!engine.running && keyEvent.getKeyCode() != KeyEvent.VK_F1 && keyEvent.getKeyCode() != KeyEvent.VK_F2 && keyEvent.getKeyCode() != KeyEvent.VK_F3 && keyEvent.getKeyCode() != KeyEvent.VK_F4 && keyEvent.getKeyCode() != KeyEvent.VK_F5) {
        startGame(engine);
        engine.running = true;
    }

    if (keyEvent.getKeyCode() == KeyEvent.VK_LEFT) {
        engine.gameBoard.directionLeft();
    } else if (keyEvent.getKeyCode() == KeyEvent.VK_RIGHT) {
        engine.gameBoard.directionRight();
    } else if (keyEvent.getKeyCode() == KeyEvent.VK_UP) {
        engine.gameBoard.directionUp();
    } else if (keyEvent.getKeyCode() == KeyEvent.VK_DOWN) {
        engine.gameBoard.directionDown();
    }

    if (keyEvent.getKeyCode() == KeyEvent.VK_F1) {
        Properties.Dark();
        repaint();
    }
    else if (keyEvent.getKeyCode() == KeyEvent.VK_F2) {
        Properties.Sky();
        repaint();
    }
    else if (keyEvent.getKeyCode() == KeyEvent.VK_F3) {
        Properties.Mud();
        repaint();
    }
    else if (keyEvent.getKeyCode() == KeyEvent.VK_F4) {
        Properties.Sand();
        repaint();
    }
    else if (keyEvent.getKeyCode() == KeyEvent.VK_F5) {
        Properties.Rainbow();
        repaint();
    }
}
 
Example 7
Source File: ReadKeyCodesTest.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent event) {
	msg1 = "";
	System.out.println("keyPressed "+event.getKeyCode());
	if (event.getKeyChar() == KeyEvent.CHAR_UNDEFINED) {
		int key = event.getKeyCode();
		// Funktionstaste abfragen
		if (key == KeyEvent.VK_F1) {
			msg1 = "F1";
		} else if (key == KeyEvent.VK_F2) {
			msg1 = "F2";
		} else if (key == KeyEvent.VK_F3) {
			msg1 = "F3";
		}
		// Modifier abfragen
		if (msg1.length() > 0) {
			if (event.isAltDown()) {
				msg1 = "ALT + " + msg1;
			}
			if (event.isControlDown()) {
				msg1 = "STRG + " + msg1;
			}
			if (event.isShiftDown()) {
				msg1 = "UMSCHALT + " + msg1;
			}
		}
	}
	repaint();
}
 
Example 8
Source File: GPTreeTableBase.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
private boolean isStartEditingEvent(KeyEvent e, boolean includeCharTyping) {
  boolean result = e.getKeyCode() == KeyEvent.VK_F2
      || e.getKeyCode() == KeyEvent.VK_INSERT
      || (myNewRowAction != null && KeyStroke.getKeyStrokeForEvent(e).equals(myNewRowAction.getKeyStroke()));
  if (!result && includeCharTyping) {
    result = e.getKeyChar() != KeyEvent.CHAR_UNDEFINED && !e.isMetaDown() && !e.isControlDown();
  }
  return result;
}
 
Example 9
Source File: ProjectToolbar.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
static public void keyPressed(KeyEvent ke) {
	switch (ke.getKeyCode()) {
		case KeyEvent.VK_F1:
			setTool(Toolbar.RECTANGLE);
			break;
		case KeyEvent.VK_F2:
			setTool(Toolbar.POLYGON);
			break;
		case KeyEvent.VK_F3:
			setTool(Toolbar.FREEROI);
			break;
		case KeyEvent.VK_F4:
			setTool(Toolbar.TEXT);
			break;
		case KeyEvent.VK_F5:
			setTool(Toolbar.MAGNIFIER);
			break;
		case KeyEvent.VK_F6:
			setTool(Toolbar.HAND);
			break;
		case KeyEvent.VK_F7:
			break;
		case KeyEvent.VK_F8:
			break;
		case KeyEvent.VK_F9:
			setTool(SELECT);
			break;
		case KeyEvent.VK_F10:
			setTool(PENCIL);
			break;
		case KeyEvent.VK_F11:
			setTool(PEN);
			break;
		case KeyEvent.VK_F12:
			setTool(BRUSH);
			break;
	}
}
 
Example 10
Source File: ActionUtils.java    From workcraft with MIT License 4 votes vote down vote up
public static String getKeyString(int keyCode) {
    // Letters and numbers
    if (((keyCode >= KeyEvent.VK_0) && (keyCode <= KeyEvent.VK_9))
            || ((keyCode >= KeyEvent.VK_A) && (keyCode <= KeyEvent.VK_Z))) {
        return String.valueOf((char) keyCode);
    }
    switch (keyCode) {
    // Navigation keys
    case KeyEvent.VK_LEFT: return "Left";
    case KeyEvent.VK_UP: return "Up";
    case KeyEvent.VK_RIGHT: return "Right";
    case KeyEvent.VK_DOWN: return "Down";
    // Extra navigation keys
    case KeyEvent.VK_INSERT: return "Insert";
    case KeyEvent.VK_DELETE: return "Delete";
    case KeyEvent.VK_END: return "End";
    case KeyEvent.VK_HOME: return "Home";
    case KeyEvent.VK_PAGE_UP: return "PgUp";
    case KeyEvent.VK_PAGE_DOWN: return "PgDn";
    // Function keys
    case KeyEvent.VK_F1: return "F1";
    case KeyEvent.VK_F2: return "F2";
    case KeyEvent.VK_F3: return "F3";
    case KeyEvent.VK_F4: return "F4";
    case KeyEvent.VK_F5: return "F5";
    case KeyEvent.VK_F6: return "F6";
    case KeyEvent.VK_F7: return "F7";
    case KeyEvent.VK_F8: return "F8";
    case KeyEvent.VK_F9: return "F9";
    case KeyEvent.VK_F10: return "F10";
    case KeyEvent.VK_F11: return "F11";
    case KeyEvent.VK_F12: return "F12";
    // Symbols
    case KeyEvent.VK_EXCLAMATION_MARK: return "!";
    case KeyEvent.VK_QUOTEDBL: return "\"";
    case KeyEvent.VK_EURO_SIGN: return "€";
    case KeyEvent.VK_DOLLAR: return "$";
    case KeyEvent.VK_CIRCUMFLEX: return "^";
    case KeyEvent.VK_AMPERSAND: return "&";
    case KeyEvent.VK_ASTERISK: return "*";
    case KeyEvent.VK_UNDERSCORE: return "_";
    case KeyEvent.VK_MINUS: return "-";
    case KeyEvent.VK_PLUS: return "+";
    case KeyEvent.VK_EQUALS: return "=";
    case KeyEvent.VK_AT: return "@";
    case KeyEvent.VK_NUMBER_SIGN: return "#";
    case KeyEvent.VK_COLON: return ":";
    case KeyEvent.VK_SEMICOLON: return ";";
    case KeyEvent.VK_COMMA: return ",";
    case KeyEvent.VK_PERIOD: return ".";
    case KeyEvent.VK_SLASH: return "/";
    case KeyEvent.VK_BACK_SLASH: return "\\";
    case KeyEvent.VK_DEAD_TILDE: return "~";
    // Parenthesis and brackets
    case KeyEvent.VK_LEFT_PARENTHESIS: return "(";
    case KeyEvent.VK_RIGHT_PARENTHESIS: return ")";
    case KeyEvent.VK_OPEN_BRACKET: return "[";
    case KeyEvent.VK_CLOSE_BRACKET: return "]";
    case KeyEvent.VK_BRACELEFT: return "{";
    case KeyEvent.VK_BRACERIGHT: return "}";
    case KeyEvent.VK_LESS: return "<";
    case KeyEvent.VK_GREATER: return ">";
    // Formatting keys
    case KeyEvent.VK_SPACE: return "Space";
    case KeyEvent.VK_TAB: return "Tab";
    case KeyEvent.VK_ENTER: return "Enter";
    case KeyEvent.VK_BACK_SPACE: return "Backspace";
    case KeyEvent.VK_ESCAPE: return "Esc";
    }
    return "0x" + Integer.toString(keyCode, 16);
}
 
Example 11
Source File: VncClientPacketSender.java    From cosmic with Apache License 2.0 4 votes vote down vote up
private int mapAwtKeyToVncKey(final int key) {
    switch (key) {
        case KeyEvent.VK_BACK_SPACE:
            return 0xff08;
        case KeyEvent.VK_TAB:
            return 0xff09;
        case KeyEvent.VK_ENTER:
            return 0xff0d;
        case KeyEvent.VK_ESCAPE:
            return 0xff1b;
        case KeyEvent.VK_INSERT:
            return 0xff63;
        case KeyEvent.VK_DELETE:
            return 0xffff;
        case KeyEvent.VK_HOME:
            return 0xff50;
        case KeyEvent.VK_END:
            return 0xff57;
        case KeyEvent.VK_PAGE_UP:
            return 0xff55;
        case KeyEvent.VK_PAGE_DOWN:
            return 0xff56;
        case KeyEvent.VK_LEFT:
            return 0xff51;
        case KeyEvent.VK_UP:
            return 0xff52;
        case KeyEvent.VK_RIGHT:
            return 0xff53;
        case KeyEvent.VK_DOWN:
            return 0xff54;
        case KeyEvent.VK_F1:
            return 0xffbe;
        case KeyEvent.VK_F2:
            return 0xffbf;
        case KeyEvent.VK_F3:
            return 0xffc0;
        case KeyEvent.VK_F4:
            return 0xffc1;
        case KeyEvent.VK_F5:
            return 0xffc2;
        case KeyEvent.VK_F6:
            return 0xffc3;
        case KeyEvent.VK_F7:
            return 0xffc4;
        case KeyEvent.VK_F8:
            return 0xffc5;
        case KeyEvent.VK_F9:
            return 0xffc6;
        case KeyEvent.VK_F10:
            return 0xffc7;
        case KeyEvent.VK_F11:
            return 0xffc8;
        case KeyEvent.VK_F12:
            return 0xffc9;
        case KeyEvent.VK_SHIFT:
            return 0xffe1;
        case KeyEvent.VK_CONTROL:
            return 0xffe3;
        case KeyEvent.VK_META:
            return 0xffe7;
        case KeyEvent.VK_ALT:
            return 0xffe9;
        case KeyEvent.VK_ALT_GRAPH:
            return 0xffea;
        case KeyEvent.VK_BACK_QUOTE:
            return 0x0060;
    }

    return key;
}
 
Example 12
Source File: AnnotationEventHook.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void processKeyEvent(final ExecutionUnit process, final KeyEventType type, final KeyEvent e) {
	if (!visualizer.isActive()) {
		return;
	}
	if (type != KeyEventType.KEY_PRESSED) {
		return;
	}
	if (model.getSelected() == null) {
		return;
	}

	switch (e.getKeyCode()) {
		case KeyEvent.VK_F2:
			decorator.editSelected();
			e.consume();
			break;
		case KeyEvent.VK_BACK_SPACE:
			if (SystemInfoUtilities.getOperatingSystem() == OperatingSystem.OSX) {
				model.deleteAnnotation(model.getSelected());
				model.setResized(null);
				model.setDragged(null);
				e.consume();
			}
			break;
		case KeyEvent.VK_DELETE:
			model.deleteAnnotation(model.getSelected());
			model.setResized(null);
			model.setDragged(null);
			e.consume();
			break;
		case KeyEvent.VK_ESCAPE:
			model.setSelected(null);
			model.stopDragOrResize(null);
			e.consume();
			break;
		default:
			break;
	}

}
 
Example 13
Source File: KeyCodesTest.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent event) {
	msg1 = "";
	System.out.println("keyPressed CODE1 "+event.getKeyCode());

	int myCode = event.getKeyCode();

	System.out.println("keyPressed CODE2 "+myCode);

	System.out.println("keyPressed CHAR3 "+event.getKeyChar());

	System.out.println("keyPressed CHAR4 "+KeyEvent.getKeyText(event.getKeyCode()));

	System.out.println("keyPressed CHAR5 "+KeyEvent.getKeyText(myCode));

	System.out.println("keyPressed isActionKey "+event.isActionKey());
	System.out.println("keyPressed isAltDown "+event.isAltDown());
	System.out.println("keyPressed isAltGraphDown "+event.isAltGraphDown());
	System.out.println("keyPressed isConsumed "+event.isConsumed());
	System.out.println("keyPressed isControlDown "+event.isControlDown());
	System.out.println("keyPressed isMetaDown "+event.isMetaDown());
	System.out.println("keyPressed isShiftDown "+event.isShiftDown());

	System.out.println("keyPressed paramString "+event.paramString());

	if (event.getKeyChar() == KeyEvent.CHAR_UNDEFINED) {
		int key = event.getKeyCode();
		// Funktionstaste abfragen
		if (key == KeyEvent.VK_F1) {
			msg1 = "F1";
		} else if (key == KeyEvent.VK_F2) {
			msg1 = "F2";
		} else if (key == KeyEvent.VK_F3) {
			msg1 = "F3";
		}
		// Modifier abfragen
		if (msg1.length() > 0) {
			if (event.isAltDown()) {
				msg1 = "ALT + " + msg1;
			}
			if (event.isControlDown()) {
				msg1 = "STRG + " + msg1;
			}
			if (event.isShiftDown()) {
				msg1 = "UMSCHALT + " + msg1;
			}
		}
	}
	repaint();
}
 
Example 14
Source File: GOSwingEventConverter.java    From settlers-remake with MIT License 4 votes vote down vote up
private String getKeyName(KeyEvent e) {
	String text = KeyEvent.getKeyText(e.getKeyCode());
	if (text == null || text.length() != 1) {
		switch (e.getKeyCode()) {
		case KeyEvent.VK_LEFT:
			text = "LEFT";
			break;
		case KeyEvent.VK_RIGHT:
			text = "RIGHT";
			break;
		case KeyEvent.VK_DOWN:
			text = "DOWN";
			break;
		case KeyEvent.VK_UP:
			text = "UP";
			break;
		case KeyEvent.VK_PAUSE:
			text = "PAUSE";
			break;
		case KeyEvent.VK_F1:
			text = "F1";
			break;
		case KeyEvent.VK_F2:
			text = "F2";
			break;
		case KeyEvent.VK_F3:
			text = "F3";
			break;
		case KeyEvent.VK_F4:
			text = "F4";
			break;
		case KeyEvent.VK_F5:
			text = "F5";
			break;
		case KeyEvent.VK_F6:
			text = "F6";
			break;
		case KeyEvent.VK_F7:
			text = "F7";
			break;
		case KeyEvent.VK_F8:
			text = "F8";
			break;
		case KeyEvent.VK_F9:
			text = "F9";
			break;
		case KeyEvent.VK_F10:
			text = "F10";
			break;
		case KeyEvent.VK_F11:
			text = "F11";
			break;
		case KeyEvent.VK_F12:
			text = "F12";
			break;
		case KeyEvent.VK_PLUS:
			text = "+";
			break;
		case KeyEvent.VK_MINUS:
			text = "-";
			break;
		case KeyEvent.VK_DELETE:
			text = "DELETE";
			break;
		case KeyEvent.VK_SPACE:
			text = " ";
			break;
		case KeyEvent.VK_ESCAPE:
			text = "ESCAPE";
			break;
		case KeyEvent.VK_BACK_SPACE:
			text = "BACK_SPACE";
			break;
		case KeyEvent.VK_TAB:
			text = "TAB";
			break;
		default:
			text = "" + e.getKeyChar();
		}
	}
	return text;
}
 
Example 15
Source File: VncClientPacketSender.java    From cloudstack with Apache License 2.0 4 votes vote down vote up
private int mapAwtKeyToVncKey(int key) {
    switch (key) {
        case KeyEvent.VK_BACK_SPACE:
            return 0xff08;
        case KeyEvent.VK_TAB:
            return 0xff09;
        case KeyEvent.VK_ENTER:
            return 0xff0d;
        case KeyEvent.VK_ESCAPE:
            return 0xff1b;
        case KeyEvent.VK_INSERT:
            return 0xff63;
        case KeyEvent.VK_DELETE:
            return 0xffff;
        case KeyEvent.VK_HOME:
            return 0xff50;
        case KeyEvent.VK_END:
            return 0xff57;
        case KeyEvent.VK_PAGE_UP:
            return 0xff55;
        case KeyEvent.VK_PAGE_DOWN:
            return 0xff56;
        case KeyEvent.VK_LEFT:
            return 0xff51;
        case KeyEvent.VK_UP:
            return 0xff52;
        case KeyEvent.VK_RIGHT:
            return 0xff53;
        case KeyEvent.VK_DOWN:
            return 0xff54;
        case KeyEvent.VK_F1:
            return 0xffbe;
        case KeyEvent.VK_F2:
            return 0xffbf;
        case KeyEvent.VK_F3:
            return 0xffc0;
        case KeyEvent.VK_F4:
            return 0xffc1;
        case KeyEvent.VK_F5:
            return 0xffc2;
        case KeyEvent.VK_F6:
            return 0xffc3;
        case KeyEvent.VK_F7:
            return 0xffc4;
        case KeyEvent.VK_F8:
            return 0xffc5;
        case KeyEvent.VK_F9:
            return 0xffc6;
        case KeyEvent.VK_F10:
            return 0xffc7;
        case KeyEvent.VK_F11:
            return 0xffc8;
        case KeyEvent.VK_F12:
            return 0xffc9;
        case KeyEvent.VK_SHIFT:
            return 0xffe1;
        case KeyEvent.VK_CONTROL:
            return 0xffe3;
        case KeyEvent.VK_META:
            return 0xffe7;
        case KeyEvent.VK_ALT:
            return 0xffe9;
        case KeyEvent.VK_ALT_GRAPH:
            return 0xffea;
        case KeyEvent.VK_BACK_QUOTE:
            return 0x0060;
    }

    return key;
}
 
Example 16
Source File: ProjectTree.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(final KeyEvent ke) {
	super.keyPressed(ke);
	if (ke.isConsumed()) return;
	if (!ke.getSource().equals(ProjectTree.this) || !project.isInputEnabled()) {
		return;
	}
	// get the first selected node only
	TreePath path = getSelectionPath();
	if (null == path) return;
	DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
	if (null == node) return;
	final ProjectThing pt = (ProjectThing)node.getUserObject();
	if (null == pt) return;
	//
	final int flags = ke.getModifiers();
	switch (ke.getKeyCode()) {
		case KeyEvent.VK_PAGE_UP:
			move(node, -1);
			ke.consume(); // in any case
			break;
		case KeyEvent.VK_PAGE_DOWN:
			move(node, 1);
			ke.consume(); // in any case
			break;
		case KeyEvent.VK_F2:
			rename(pt);
			ke.consume();
			break;
		case KeyEvent.VK_H:
			if (0 == (flags ^ Event.ALT_MASK)) {
				pt.setVisible(true);
				ke.consume();
			} else if (0 == flags) {
				pt.setVisible(false);
				ke.consume();
			}
			break;
		case KeyEvent.VK_A:
			if (0 == flags || (0 == (flags ^ Event.SHIFT_MASK))) {
				selectInDisplay(pt, 0 == (flags ^ Event.SHIFT_MASK));
				ke.consume();
			}
			break;
		case KeyEvent.VK_3:
			if (0 == flags) {
				ini.trakem2.display.Display3D.showAndResetView(pt);
				ke.consume();
				break;
			}
			// else, flow:
		case KeyEvent.VK_1:
		case KeyEvent.VK_2:
		case KeyEvent.VK_4:
		case KeyEvent.VK_5:
		case KeyEvent.VK_6:
		case KeyEvent.VK_7:
		case KeyEvent.VK_8:
		case KeyEvent.VK_9:
			// run a plugin, if any
			if (pt.getObject() instanceof Displayable && null != Utils.launchTPlugIn(ke, "Project Tree", project, (Displayable)pt.getObject())) {
				ke.consume();
			}
			break;
	}
	ke.consume();
}