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

The following examples show how to use java.awt.event.KeyEvent#VK_H . 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: MainFrame.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the help menu.
 *
 * @return the j menu
 */
private JMenu createHelpMenu() {
  JMenu helpMenu = new JMenu("Help");
  helpMenu.setMnemonic(KeyEvent.VK_H);
  JMenuItem manualItem = new JMenuItem("Manual", KeyEvent.VK_M);
  manualItem.addActionListener(new ManualHandler(this));
  helpMenu.add(manualItem);
  JMenuItem helpInfoItem = new JMenuItem("Help", KeyEvent.VK_H);
  helpInfoItem.addActionListener(new HelpHandler(this));
  helpMenu.add(helpInfoItem);
  helpMenu.addSeparator();
  JMenuItem aboutItem = new JMenuItem("About CVD", KeyEvent.VK_A);
  aboutItem.addActionListener(new AboutHandler(this));
  helpMenu.add(aboutItem);
  JMenuItem aboutUimaItem = new JMenuItem("About UIMA", KeyEvent.VK_U);
  aboutUimaItem.addActionListener(new AboutUimaHandler(this));
  helpMenu.add(aboutUimaItem);
  return helpMenu;
}
 
Example 2
Source File: ArcActionTest.java    From PIPE with MIT License 6 votes vote down vote up
@Before
public void setUp() {
    when(mockController.getPetriNet()).thenReturn(mockNet);

    when(mockApplicationView.getSelectedTokenName()).thenReturn(ACTIVE_TOKEN_ID);

    when(mockController.getPetriNetTab()).thenReturn(mockTab);
    when(mockController.getSelectedToken()).thenReturn(ACTIVE_TOKEN_ID);

    when(mockApplicationController.getActivePetriNetController()).thenReturn(mockController);

    action = new ArcAction("Inhibitor Arc", "Add an inhibitor arc", KeyEvent.VK_H, InputEvent.ALT_DOWN_MASK,
            mockSourceVisitor, mockCreatorVisitor, applicationModel, mockApplicationController,
            new InhibitorArcHead());
    action.addUndoableEditListener(listener);
}
 
Example 3
Source File: Utilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static boolean usableKeyOnMac(int key, int mask) {
    //All permutations fail for Q except ctrl
    if (key == KeyEvent.VK_Q) {
        return false;
    }

    boolean isMeta = ((mask & KeyEvent.META_MASK) != 0) || ((mask & KeyEvent.CTRL_DOWN_MASK) != 0);

    boolean isAlt = ((mask & KeyEvent.ALT_MASK) != 0) || ((mask & KeyEvent.ALT_DOWN_MASK) != 0);

    boolean isOnlyMeta = isMeta && ((mask & ~(KeyEvent.META_DOWN_MASK | KeyEvent.META_MASK)) == 0);

    //Mac OS consumes keys Command+ these keys - the app will never see
    //them, so CTRL should not be remapped for these
    if (isOnlyMeta) {
        return (key != KeyEvent.VK_H) && (key != KeyEvent.VK_SPACE) && (key != KeyEvent.VK_TAB);
    }
    if ((key == KeyEvent.VK_D) && isMeta && isAlt) {
        return false;
    }
    if (key == KeyEvent.VK_SPACE && isMeta && ((mask & KeyEvent.CTRL_MASK) != 0)) {
        // http://lists.apple.com/archives/java-dev/2010/Aug/msg00002.html
        return false;
    }
    return true;
}
 
Example 4
Source File: KeyboardSupport.java    From CrossMobile with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void reactToReleaseEvent(CEventCallback callback, int vk_event, int modifier) {
    switch (vk_event) {
        case KeyEvent.VK_CONTROL:
            if ((mask & MULTITOUCH.mask) != 0)
                callback.endMultiTouch();
            break;
        case KeyEvent.VK_B:
        case KeyEvent.VK_BACK_SPACE:
            if ((mask & BACK.mask) != 0)
                callback.back();
            break;
        case KeyEvent.VK_P:
        case KeyEvent.VK_SPACE:
            if ((mask & PAUSE.mask) != 0)
                ((DesktopLifecycleBridge) Native.lifecycle()).toggleActivation();
            break;
        case KeyEvent.VK_ESCAPE:
        case KeyEvent.VK_Q:
            if ((mask & QUIT.mask) != 0)
                callback.powerOff();
            break;
        case KeyEvent.VK_M:
            if (modifier == KeyEvent.CTRL_MASK)
                memoryWarning();
            break;
        case KeyEvent.VK_H:
        case KeyEvent.VK_HOME:
            if ((mask & HOME.mask) != 0)
                callback.home();
            break;
        case KeyEvent.VK_LEFT:
            if ((mask & ROTATE.mask) != 0)
                callback.rotateLeft();
            break;
        case KeyEvent.VK_RIGHT:
            if ((mask & ROTATE.mask) != 0)
                callback.rotateRight();
            break;
    }
}
 
Example 5
Source File: ComponentCreatorManager.java    From PIPE with MIT License 5 votes vote down vote up
public ComponentCreatorManager(UndoableEditListener undoListener, PipeApplicationModel applicationModel,
                               PipeApplicationController applicationController) {
    placeAction = new PlaceAction(applicationModel);

    transAction = new ImmediateTransitionAction(applicationModel);

    timedtransAction = new TimedTransitionAction(applicationModel);

    annotationAction = new AnnotationAction(applicationModel);

    inhibarcAction =
            new ArcAction("Inhibitor Arc", "Add an inhibitor arc (alt-h)", KeyEvent.VK_H, InputEvent.ALT_DOWN_MASK,
                    new InhibitorSourceVisitor(), new InhibitorCreator(), applicationModel,
                    applicationController, new InhibitorArcHead());
    arcAction = new ArcAction("Arc", "Add an arc (alt-a)", KeyEvent.VK_A, InputEvent.ALT_DOWN_MASK,
            new NormalArcSourceVisitor(), new NormalCreator(applicationController), applicationModel,
            applicationController,
            new NormalHead());

    rateParameterAction = new SpecifyRateParameterAction(applicationController);

    placeAction.addUndoableEditListener(undoListener);
    transAction.addUndoableEditListener(undoListener);
    timedtransAction.addUndoableEditListener(undoListener);
    arcAction.addUndoableEditListener(undoListener);
    inhibarcAction.addUndoableEditListener(undoListener);
    annotationAction.addUndoableEditListener(undoListener);
    rateParameterAction.addUndoableEditListener(undoListener);
}
 
Example 6
Source File: UndoFixedEditorPane.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void processKeyEvent(KeyEvent ke) {
    if (!isEditable()) {
        // disable Ctrl-E: delete line
        // and Ctrl-H: Search and replace
        if ((ke.getKeyCode() == KeyEvent.VK_E && ke.isControlDown())
                || (ke.getKeyCode() == KeyEvent.VK_H && ke.isControlDown())) {
            return;
        }
    }

    super.processKeyEvent(ke);
}
 
Example 7
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();
}
 
Example 8
Source File: MissingCharsKorean.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static boolean setKeyInput(int iCount) {
    boolean inputSet = true;

    switch(iCount) {
        case 0:
            // Input Korean q (#12610) /(#47)
            expectedResults = new int[]{ 12610, 47 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH}
                                    };
            break;

        case 1:
            // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
            expectedResults = new int[]{ 12610, 47, 54840, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 2:
            // Input Korean q (#12610) /(#47) ghq (#54857) \(#92)
            expectedResults = new int[]{ 12610, 47, 54857, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 3:
            // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
            expectedResults = new int[]{ 12610, 47, 54840, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 4:
            // Input Korean q (#12610) /(#47) g (#12622) \(#92)
            expectedResults = new int[]{ 12610, 47, 12622, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        default:
            inputSet = false;
            break;
    }

    return inputSet;
}
 
Example 9
Source File: MenuInput.java    From JavaGame with GNU Affero General Public License v3.0 4 votes vote down vote up
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;
		}
	}
 
Example 10
Source File: GrammarVizView.java    From grammarviz2_src with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Build the application menu bar.
 */
private void buildMenuBar() {

  // Build the File menu.
  //
  //
  JMenu fileMenu = new JMenu("File");
  fileMenu.setMnemonic(KeyEvent.VK_F);
  fileMenu.getAccessibleContext().setAccessibleDescription("The file menu");
  // Open file item
  JMenuItem openFileItem = new JMenuItem("Select", KeyEvent.VK_O);
  openFileItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
  openFileItem.getAccessibleContext().setAccessibleDescription("Open a data file");
  openFileItem.setActionCommand(SELECT_FILE);
  openFileItem.addActionListener(this);
  fileMenu.add(openFileItem);
  // add a separator
  fileMenu.addSeparator();
  // an exit item
  JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X);
  exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
  exitItem.getAccessibleContext().setAccessibleDescription("Exit from here");
  exitItem.addActionListener(this);
  fileMenu.add(exitItem);

  // Build the Options menu.
  //
  //
  JMenu settingsMenu = new JMenu("Settings");
  settingsMenu.setMnemonic(KeyEvent.VK_S);
  settingsMenu.getAccessibleContext().setAccessibleDescription("Settings menu");
  // an exit item
  JMenuItem optionsItem = new JMenuItem("GrammarViz options", KeyEvent.VK_P);
  optionsItem.setActionCommand(OPTIONS_MENU_ITEM);
  optionsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));
  optionsItem.getAccessibleContext().setAccessibleDescription("Options");
  optionsItem.addActionListener(this);
  settingsMenu.add(optionsItem);

  // Build the About menu.
  JMenu helpMenu = new JMenu("Help");
  helpMenu.setMnemonic(KeyEvent.VK_F1);
  helpMenu.getAccessibleContext().setAccessibleDescription("Help & About");

  // a help item
  JMenuItem helpItem = new JMenuItem("Help", KeyEvent.VK_H);
  helpItem.getAccessibleContext().setAccessibleDescription("Get some help here.");
  exitItem.addActionListener(controller);
  helpMenu.add(helpItem);

  // an about item
  JMenuItem aboutItem = new JMenuItem("About", KeyEvent.VK_A);
  aboutItem.getAccessibleContext().setAccessibleDescription("About the app.");
  aboutItem.setActionCommand(ABOUT_MENU_ITEM);
  aboutItem.addActionListener(this);
  helpMenu.add(aboutItem);

  // make sure that controller is connected with Exit item
  //
  exitItem.addActionListener(controller);

  menuBar.add(fileMenu);
  menuBar.add(settingsMenu);
  menuBar.add(helpMenu);
}
 
Example 11
Source File: MissingCharsKorean.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static boolean setKeyInput(int iCount) {
    boolean inputSet = true;

    switch(iCount) {
        case 0:
            // Input Korean q (#12610) /(#47)
            expectedResults = new int[]{ 12610, 47 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH}
                                    };
            break;

        case 1:
            // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
            expectedResults = new int[]{ 12610, 47, 54840, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 2:
            // Input Korean q (#12610) /(#47) ghq (#54857) \(#92)
            expectedResults = new int[]{ 12610, 47, 54857, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 3:
            // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
            expectedResults = new int[]{ 12610, 47, 54840, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 4:
            // Input Korean q (#12610) /(#47) g (#12622) \(#92)
            expectedResults = new int[]{ 12610, 47, 12622, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        default:
            inputSet = false;
            break;
    }

    return inputSet;
}
 
Example 12
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 4 votes vote down vote up
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 "";
	}
}
 
Example 13
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 4 votes vote down vote up
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 "";
	}
}
 
Example 14
Source File: Robot.java    From xnx3 with Apache License 2.0 4 votes vote down vote up
/**
 * 将字符型转换为按键码,可直接使用 {@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;
}
 
Example 15
Source File: MissingCharsKorean.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static boolean setKeyInput(int iCount) {
    boolean inputSet = true;

    switch(iCount) {
        case 0:
            // Input Korean q (#12610) /(#47)
            expectedResults = new int[]{ 12610, 47 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH}
                                    };
            break;

        case 1:
            // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
            expectedResults = new int[]{ 12610, 47, 54840, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 2:
            // Input Korean q (#12610) /(#47) ghq (#54857) \(#92)
            expectedResults = new int[]{ 12610, 47, 54857, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 3:
            // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
            expectedResults = new int[]{ 12610, 47, 54840, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 4:
            // Input Korean q (#12610) /(#47) g (#12622) \(#92)
            expectedResults = new int[]{ 12610, 47, 12622, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        default:
            inputSet = false;
            break;
    }

    return inputSet;
}
 
Example 16
Source File: MissingCharsKorean.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static boolean setKeyInput(int iCount) {
    boolean inputSet = true;

    switch(iCount) {
        case 0:
            // Input Korean q (#12610) /(#47)
            expectedResults = new int[]{ 12610, 47 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH}
                                    };
            break;

        case 1:
            // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
            expectedResults = new int[]{ 12610, 47, 54840, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 2:
            // Input Korean q (#12610) /(#47) ghq (#54857) \(#92)
            expectedResults = new int[]{ 12610, 47, 54857, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 3:
            // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
            expectedResults = new int[]{ 12610, 47, 54840, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 4:
            // Input Korean q (#12610) /(#47) g (#12622) \(#92)
            expectedResults = new int[]{ 12610, 47, 12622, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        default:
            inputSet = false;
            break;
    }

    return inputSet;
}
 
Example 17
Source File: PlotFrame.java    From opt4j with MIT License 4 votes vote down vote up
/**
 * 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);
}
 
Example 18
Source File: PlotFrame.java    From OpenDA with GNU Lesser General Public License v3.0 4 votes vote down vote up
/** 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);
}
 
Example 19
Source File: MissingCharsKorean.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static boolean setKeyInput(int iCount) {
    boolean inputSet = true;

    switch(iCount) {
        case 0:
            // Input Korean q (#12610) /(#47)
            expectedResults = new int[]{ 12610, 47 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH}
                                    };
            break;

        case 1:
            // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
            expectedResults = new int[]{ 12610, 47, 54840, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 2:
            // Input Korean q (#12610) /(#47) ghq (#54857) \(#92)
            expectedResults = new int[]{ 12610, 47, 54857, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 3:
            // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
            expectedResults = new int[]{ 12610, 47, 54840, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        case 4:
            // Input Korean q (#12610) /(#47) g (#12622) \(#92)
            expectedResults = new int[]{ 12610, 47, 12622, 92 };
            inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
                                        {KeyEvent.VK_SLASH},
                                        {KeyEvent.VK_G},
                                        {KeyEvent.VK_H},
                                        {KeyEvent.VK_Q},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SPACE},
                                        {KeyEvent.VK_BACK_SLASH}
                                    };
            break;

        default:
            inputSet = false;
            break;
    }

    return inputSet;
}