List of usage examples for java.awt.event KeyEvent VK_F3
int VK_F3
To view the source code for java.awt.event KeyEvent VK_F3.
Click Source Link
From source file:ToggleSample.java
public static void main(String args[]) { JFrame frame = new JFrame("JToggleButtonMenuItem Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu file = new JMenu("File"); file.setMnemonic('f'); JMenuItem newItem = new JMenuItem("New", 'N'); file.add(newItem);//from www . jav a2 s . co m JMenuItem openItem = new JMenuItem("Open", 'O'); file.add(openItem); JMenuItem closeItem = new JMenuItem("Close", 'C'); file.add(closeItem); file.addSeparator(); JMenuItem saveItem = new JMenuItem("Save", 'S'); file.add(saveItem); file.addSeparator(); JMenuItem exitItem = new JMenuItem("Exit", 'X'); file.add(exitItem); bar.add(file); JMenu edit = new JMenu("Edit"); JMenuItem cutItem = new JMenuItem("Cut", 'T'); cutItem.setAccelerator(KeyStroke.getKeyStroke('X', Event.CTRL_MASK)); edit.add(cutItem); JMenuItem copyItem = new JMenuItem("Copy", 'C'); copyItem.setAccelerator(KeyStroke.getKeyStroke('C', Event.CTRL_MASK)); edit.add(copyItem); JMenuItem pasteItem = new JMenuItem("Paste", 'P'); pasteItem.setAccelerator(KeyStroke.getKeyStroke('V', Event.CTRL_MASK)); pasteItem.setEnabled(false); edit.add(pasteItem); edit.addSeparator(); JMenuItem findItem = new JMenuItem("Find", 'F'); findItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); edit.add(findItem); edit.setMnemonic('e'); Icon atIcon = new ImageIcon("at.gif"); JMenu findOptions = new JMenu("Options"); findOptions.setIcon(atIcon); findOptions.setMnemonic('O'); ButtonGroup directionGroup = new ButtonGroup(); JRadioButtonMenuItem forward = new JRadioButtonMenuItem("Forward", true); findOptions.add(forward); directionGroup.add(forward); JRadioButtonMenuItem backward = new JRadioButtonMenuItem("Backward"); findOptions.add(backward); directionGroup.add(backward); findOptions.addSeparator(); JCheckBoxMenuItem caseItem = new JCheckBoxMenuItem("Case Insensitive"); findOptions.add(caseItem); edit.add(findOptions); JToggleButtonMenuItem toggleItem = new JToggleButtonMenuItem("Ballon Help"); toggleItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Selected"); } }); edit.add(toggleItem); bar.add(edit); frame.setJMenuBar(bar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:SwingToolBarSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Action Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Action showAction = new ShowAction(frame); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); JMenuItem newMenuItem = new JMenuItem("New", 'N'); fileMenu.add(newMenuItem);//from w w w . java2s. c om JMenuItem openMenuItem = new JMenuItem("Open", 'O'); fileMenu.add(openMenuItem); JMenuItem closeMenuItem = new JMenuItem("Close", 'C'); fileMenu.add(closeMenuItem); fileMenu.addSeparator(); JMenuItem saveMenuItem = new JMenuItem("Save", 'S'); fileMenu.add(saveMenuItem); fileMenu.add(showAction); fileMenu.addSeparator(); JMenuItem exitMenuItem = new JMenuItem("Exit", 'X'); fileMenu.add(exitMenuItem); menuBar.add(fileMenu); JMenu editMenu = new JMenu("Edit"); JMenuItem cutMenuItem = new JMenuItem("Cut", 'T'); KeyStroke ctrlXKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK); cutMenuItem.setAccelerator(ctrlXKeyStroke); editMenu.add(cutMenuItem); JMenuItem copyMenuItem = new JMenuItem("Copy", 'C'); KeyStroke ctrlCKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK); copyMenuItem.setAccelerator(ctrlCKeyStroke); editMenu.add(copyMenuItem); JMenuItem pasteMenuItem = new JMenuItem("Paste", 'P'); KeyStroke ctrlVKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK); pasteMenuItem.setAccelerator(ctrlVKeyStroke); pasteMenuItem.setEnabled(false); editMenu.add(pasteMenuItem); editMenu.addSeparator(); JMenuItem findMenuItem = new JMenuItem("Find", 'F'); KeyStroke f3KeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0); findMenuItem.setAccelerator(f3KeyStroke); editMenu.add(findMenuItem); editMenu.setMnemonic('e'); editMenu.add(showAction); menuBar.add(editMenu); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:MenuX.java
public static void main(String args[]) { ActionListener actionListener = new MenuActionListener(); MenuKeyListener menuKeyListener = new MyMenuKeyListener(); ChangeListener cListener = new MyChangeListener(); MenuListener menuListener = new MyMenuListener(); MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.addChangeListener(cListener); JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new VerticalMenuBar(); // JMenuBar bar = new JMenuBar(); // File Menu, F - Mnemonic JMenu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); file.addChangeListener(cListener);/*from w w w . j a v a 2s.co m*/ file.addMenuListener(menuListener); file.addMenuKeyListener(menuKeyListener); JPopupMenu popupMenu = file.getPopupMenu(); popupMenu.setLayout(new GridLayout(3, 3)); bar.add(file); // File->New, N - Mnemonic JMenuItem newItem = new JMenuItem("New", KeyEvent.VK_N); newItem.addActionListener(actionListener); newItem.addChangeListener(cListener); newItem.addMenuKeyListener(menuKeyListener); file.add(newItem); // File->Open, O - Mnemonic JMenuItem openItem = new JMenuItem("Open", KeyEvent.VK_O); openItem.addActionListener(actionListener); openItem.addChangeListener(cListener); openItem.addMenuKeyListener(menuKeyListener); file.add(openItem); // File->Close, C - Mnemonic JMenuItem closeItem = new JMenuItem("Close", KeyEvent.VK_C); closeItem.addActionListener(actionListener); closeItem.addChangeListener(cListener); closeItem.addMenuKeyListener(menuKeyListener); file.add(closeItem); // Separator file.addSeparator(); // File->Save, S - Mnemonic JMenuItem saveItem = new JMenuItem("Save", KeyEvent.VK_S); saveItem.addActionListener(actionListener); saveItem.addChangeListener(cListener); saveItem.addMenuKeyListener(menuKeyListener); file.add(saveItem); // Separator file.addSeparator(); // File->Exit, X - Mnemonic JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X); exitItem.addActionListener(actionListener); exitItem.addChangeListener(cListener); exitItem.addMenuKeyListener(menuKeyListener); file.add(exitItem); // Edit Menu, E - Mnemonic JMenu edit = new JMenu("Edit"); edit.setMnemonic(KeyEvent.VK_E); edit.addChangeListener(cListener); edit.addMenuListener(menuListener); edit.addMenuKeyListener(menuKeyListener); bar.add(edit); // Edit->Cut, T - Mnemonic, CTRL-X - Accelerator JMenuItem cutItem = new JMenuItem("Cut", KeyEvent.VK_T); cutItem.addActionListener(actionListener); cutItem.addChangeListener(cListener); cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK)); cutItem.addMenuKeyListener(menuKeyListener); edit.add(cutItem); // Edit->Copy, C - Mnemonic, CTRL-C - Accelerator JMenuItem copyItem = new JMenuItem("Copy", KeyEvent.VK_C); copyItem.addActionListener(actionListener); copyItem.addChangeListener(cListener); copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); copyItem.addMenuKeyListener(menuKeyListener); copyItem.setEnabled(false); edit.add(copyItem); // Edit->Paste, P - Mnemonic, CTRL-V - Accelerator, Disabled JMenuItem pasteItem = new JMenuItem("Paste", KeyEvent.VK_P); pasteItem.addActionListener(actionListener); pasteItem.addChangeListener(cListener); pasteItem.addMenuKeyListener(menuKeyListener); pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK)); pasteItem.setEnabled(false); edit.add(pasteItem); // Separator edit.addSeparator(); // Edit->Find, F - Mnemonic, F3 - Accelerator JMenuItem findItem = new JMenuItem("Find", KeyEvent.VK_F); findItem.addActionListener(actionListener); findItem.addChangeListener(cListener); findItem.addMenuKeyListener(menuKeyListener); findItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); edit.add(findItem); // Edit->Options Submenu, O - Mnemonic, at.gif - Icon Image File JMenu findOptions = new JMenu("Options"); findOptions.addChangeListener(cListener); findOptions.addMenuListener(menuListener); findOptions.addMenuKeyListener(menuKeyListener); Icon atIcon = new ImageIcon("at.gif"); findOptions.setIcon(atIcon); findOptions.setMnemonic(KeyEvent.VK_O); // ButtonGrou for radio buttons ButtonGroup directionGroup = new ButtonGroup(); // Edit->Options->Forward, F - Mnemonic, in group JRadioButtonMenuItem forward = new JRadioButtonMenuItem("Forward", true); forward.addActionListener(actionListener); forward.addChangeListener(cListener); forward.addMenuKeyListener(menuKeyListener); forward.setMnemonic(KeyEvent.VK_F); findOptions.add(forward); directionGroup.add(forward); // Edit->Options->Backward, B - Mnemonic, in group JRadioButtonMenuItem backward = new JRadioButtonMenuItem("Backward"); backward.addActionListener(actionListener); backward.addChangeListener(cListener); backward.addMenuKeyListener(menuKeyListener); backward.setMnemonic(KeyEvent.VK_B); findOptions.add(backward); directionGroup.add(backward); // Separator findOptions.addSeparator(); // Edit->Options->Case Sensitive, C - Mnemonic JCheckBoxMenuItem caseItem = new JCheckBoxMenuItem("Case Sensitive"); caseItem.addActionListener(actionListener); caseItem.addChangeListener(cListener); caseItem.addMenuKeyListener(menuKeyListener); caseItem.setMnemonic(KeyEvent.VK_C); findOptions.add(caseItem); edit.add(findOptions); frame.setJMenuBar(bar); // frame.getContentPane().add(bar, BorderLayout.EAST); frame.setSize(350, 250); frame.setVisible(true); }
From source file:MenuY.java
public static void main(String args[]) { ActionListener actionListener = new MenuActionListener(); MenuKeyListener menuKeyListener = new MyMenuKeyListener(); ChangeListener cListener = new MyChangeListener(); MenuListener menuListener = new MyMenuListener(); MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.addChangeListener(cListener); JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new VerticalMenuBar(); // JMenuBar bar = new JMenuBar(); // File Menu, F - Mnemonic JMenu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); file.addChangeListener(cListener);//from ww w . ja v a2 s. c o m file.addMenuListener(menuListener); file.addMenuKeyListener(menuKeyListener); JPopupMenu popupMenu = file.getPopupMenu(); popupMenu.setLayout(new GridLayout(3, 3)); bar.add(file); // File->New, N - Mnemonic JMenuItem newItem = new JMenuItem("New", KeyEvent.VK_N); newItem.addActionListener(actionListener); newItem.addChangeListener(cListener); newItem.addMenuKeyListener(menuKeyListener); file.add(newItem); // File->Open, O - Mnemonic JMenuItem openItem = new JMenuItem("Open", KeyEvent.VK_O); openItem.addActionListener(actionListener); openItem.addChangeListener(cListener); openItem.addMenuKeyListener(menuKeyListener); file.add(openItem); // File->Close, C - Mnemonic JMenuItem closeItem = new JMenuItem("Close", KeyEvent.VK_C); closeItem.addActionListener(actionListener); closeItem.addChangeListener(cListener); closeItem.addMenuKeyListener(menuKeyListener); file.add(closeItem); // Separator file.addSeparator(); // File->Save, S - Mnemonic JMenuItem saveItem = new JMenuItem("Save", KeyEvent.VK_S); saveItem.addActionListener(actionListener); saveItem.addChangeListener(cListener); saveItem.addMenuKeyListener(menuKeyListener); file.add(saveItem); // Separator file.addSeparator(); // File->Exit, X - Mnemonic JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X); exitItem.addActionListener(actionListener); exitItem.addChangeListener(cListener); exitItem.addMenuKeyListener(menuKeyListener); file.add(exitItem); // Edit Menu, E - Mnemonic JMenu edit = new JMenu("Edit"); edit.setMnemonic(KeyEvent.VK_E); edit.addChangeListener(cListener); edit.addMenuListener(menuListener); edit.addMenuKeyListener(menuKeyListener); bar.add(edit); // Edit->Cut, T - Mnemonic, CTRL-X - Accelerator JMenuItem cutItem = new JMenuItem("Cut", KeyEvent.VK_T); cutItem.addActionListener(actionListener); cutItem.addChangeListener(cListener); cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK)); cutItem.addMenuKeyListener(menuKeyListener); edit.add(cutItem); // Edit->Copy, C - Mnemonic, CTRL-C - Accelerator JMenuItem copyItem = new JMenuItem("Copy", KeyEvent.VK_C); copyItem.addActionListener(actionListener); copyItem.addChangeListener(cListener); copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); copyItem.addMenuKeyListener(menuKeyListener); copyItem.setEnabled(false); edit.add(copyItem); // Edit->Paste, P - Mnemonic, CTRL-V - Accelerator, Disabled JMenuItem pasteItem = new JMenuItem("Paste", KeyEvent.VK_P); pasteItem.addActionListener(actionListener); pasteItem.addChangeListener(cListener); pasteItem.addMenuKeyListener(menuKeyListener); pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK)); pasteItem.setEnabled(false); edit.add(pasteItem); // Separator edit.addSeparator(); // Edit->Find, F - Mnemonic, F3 - Accelerator JMenuItem findItem = new JMenuItem("Find", KeyEvent.VK_F); findItem.addActionListener(actionListener); findItem.addChangeListener(cListener); findItem.addMenuKeyListener(menuKeyListener); findItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); edit.add(findItem); // Edit->Options Submenu, O - Mnemonic, at.gif - Icon Image File Icon atIcon = new ImageIcon("at.gif"); Action findAction = new AbstractAction("Options", atIcon) { ActionListener actionListener = new MenuActionListener(); public void actionPerformed(ActionEvent e) { actionListener.actionPerformed(e); } }; findAction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_O)); JMenuItem jMenuItem = new JMenuItem(findAction); JMenu findOptions = new JMenu(findAction); findOptions.addChangeListener(cListener); findOptions.addMenuListener(menuListener); findOptions.addMenuKeyListener(menuKeyListener); // ButtonGrou for radio buttons ButtonGroup directionGroup = new ButtonGroup(); // Edit->Options->Forward, F - Mnemonic, in group JRadioButtonMenuItem forward = new JRadioButtonMenuItem("Forward", true); forward.addActionListener(actionListener); forward.addChangeListener(cListener); forward.addMenuKeyListener(menuKeyListener); forward.setMnemonic(KeyEvent.VK_F); findOptions.add(forward); directionGroup.add(forward); // Edit->Options->Backward, B - Mnemonic, in group JRadioButtonMenuItem backward = new JRadioButtonMenuItem("Backward"); backward.addActionListener(actionListener); backward.addChangeListener(cListener); backward.addMenuKeyListener(menuKeyListener); backward.setMnemonic(KeyEvent.VK_B); findOptions.add(backward); directionGroup.add(backward); // Separator findOptions.addSeparator(); // Edit->Options->Case Sensitive, C - Mnemonic JCheckBoxMenuItem caseItem = new JCheckBoxMenuItem("Case Sensitive"); caseItem.addActionListener(actionListener); caseItem.addChangeListener(cListener); caseItem.addMenuKeyListener(menuKeyListener); caseItem.setMnemonic(KeyEvent.VK_C); findOptions.add(caseItem); edit.add(findOptions); frame.setJMenuBar(bar); // frame.getContentPane().add(bar, BorderLayout.EAST); frame.setSize(350, 250); frame.setVisible(true); }
From source file:com.au.splashinc.JControl.Load.DarkForcesJsonLoader.java
public void LoadConfig() { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //JSON organised in [Button/Axis/POV],{[TypeofAction],[Value]} /*W- up - LeftStick Up A - Left - Right Stick Left - X Rot - S - back - LeftStick Down - Y Axis up d - right - Right Stick Right - x Rot + Space - jump - A - 1/*from www. j av a2 s. c o m*/ c - Crouch - Right Stick In - 10 Mouse 1 - primary fire - Right Trigger - z axis - Shift - Run - Left Stick in - 9 Capslock - Walk - LB - 5 e - Open/interact - B - 2 R - Secondary Fire - Left Trigger - z axis + Pageup - Look Up - Right Stick Up - Y Rot - PageDown - Loop Down - Right Stick Down - y Rot + f1 - pda - Back - 3 f2 - night vision - dpad down f3- fleats - dpad left f4 - gasmask - dpad right f5 - headlamp - dpad up*/ JSONArray simpleKey = new JSONArray(); simpleKey.add(GetJSONObject("Button 0", KeyEvent.VK_SPACE)); simpleKey.add(GetJSONObject("Button 2", KeyEvent.VK_E)); simpleKey.add(GetJSONObject("Button 8", KeyEvent.VK_F1)); simpleKey.add(GetJSONObject("Button 7", KeyEvent.VK_CAPS_LOCK)); simpleKey.add(GetJSONObject("Button 3", KeyEvent.VK_SHIFT)); simpleKey.add(GetJSONObject("Button 1", KeyEvent.VK_C)); simpleKey.add(GetJSONObject("X Axis -", KeyEvent.VK_A)); simpleKey.add(GetJSONObject("X Axis +", KeyEvent.VK_D)); simpleKey.add(GetJSONObject("Y Axis -", KeyEvent.VK_W)); simpleKey.add(GetJSONObject("Y Axis +", KeyEvent.VK_S)); simpleKey.add(GetJSONObject("Hat Switch 0 0.25", KeyEvent.VK_F5)); simpleKey.add(GetJSONObject("Hat Switch 0 0.5", KeyEvent.VK_F4)); simpleKey.add(GetJSONObject("Hat Switch 0 0.75", KeyEvent.VK_F2)); simpleKey.add(GetJSONObject("Hat Switch 0 1.0", KeyEvent.VK_F3)); simpleKey.add(GetJSONObject("Z Axis +", KeyEvent.VK_R)); simpleKey.add(GetJSONObject("Y Rotation +", KeyEvent.VK_PAGE_UP)); simpleKey.add(GetJSONObject("Y Rotation -", KeyEvent.VK_PAGE_DOWN)); JSONArray simpleMouse = new JSONArray(); simpleMouse.add(GetJSONObject("X Rotation", "LeftRight")); simpleMouse.add(GetJSONObject("Z Axis -", InputEvent.BUTTON1_MASK)); //JSONObject jo = new JSONObject(); //jo.put("Button 0", KeyEvent.VK_SPACE); //jo.put("Button 2", KeyEvent.VK_E); //jo.pu //simpleKey.add(jo); /*JSONObject j1 = new JSONObject(); j1.put("Button 2", KeyEvent.VK_E); simpleKey.add(j1);*/ json.put(ControllerAction.SIMPLE_BUTTON.toString(), simpleKey); json.put(ControllerAction.SIMPLE_MOUSE.toString(), simpleMouse); /*json.put("Button 0", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_SPACE)); json.put("Button 2", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_E)); json.put("Button 8", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_F1)); json.put("Button 7", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_CAPS_LOCK)); json.put("Button 3", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_SHIFT)); json.put("Button 1", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_C)); json.put("X Axis -", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_A)); json.put("X Axis +", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_D)); json.put("Y Axis -", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_W)); json.put("Y Axis +", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_S)); json.put("Hat Switch 0 0.25", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_F5)); json.put("Hat Switch 0 0.5", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_F4)); json.put("Hat Switch 0 0.75", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_F2)); json.put("Hat Switch 0 1.0", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_F3)); json.put("Z Axis +", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_R)); json.put("Z Axis -", GetSimpleButton(ControllerAction.SIMPLE_MOUSE.toString(), InputEvent.BUTTON1_MASK)); json.put("X Rotation", GetSimpleButton(ControllerAction.SIMPLE_MOUSE.toString(), "LeftRight")); json.put("Y Rotation +", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_PAGE_UP)); json.put("Y Rotation -", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_PAGE_DOWN));*/ //json.put("Button 4,5", this) controllerDetail = json.toJSONString(); System.out.println(json.toJSONString()); JsonLoaderHelper jsh = new JsonLoaderHelper(json); keyDownMap = jsh.getKeyDownMap(); keyUpMap = jsh.getKeyUpMap(); mouseMoveMap = jsh.getMouseMoveMap(); mouseButtonDownMap = jsh.getMouseButtonDownMap(); mouseButtonUpMap = jsh.getMouseButtonUpMap(); }
From source file:Main.java
public static String getKeyText(int keyCode) { if (keyCode >= KeyEvent.VK_0 && keyCode <= KeyEvent.VK_9 || keyCode >= KeyEvent.VK_A && keyCode <= KeyEvent.VK_Z) { return String.valueOf((char) keyCode); }//from w w w.j a v a 2s . c om switch (keyCode) { case KeyEvent.VK_COMMA: return "COMMA"; case KeyEvent.VK_PERIOD: return "PERIOD"; case KeyEvent.VK_SLASH: return "SLASH"; case KeyEvent.VK_SEMICOLON: return "SEMICOLON"; case KeyEvent.VK_EQUALS: return "EQUALS"; case KeyEvent.VK_OPEN_BRACKET: return "OPEN_BRACKET"; case KeyEvent.VK_BACK_SLASH: return "BACK_SLASH"; case KeyEvent.VK_CLOSE_BRACKET: return "CLOSE_BRACKET"; case KeyEvent.VK_ENTER: return "ENTER"; case KeyEvent.VK_BACK_SPACE: return "BACK_SPACE"; case KeyEvent.VK_TAB: return "TAB"; case KeyEvent.VK_CANCEL: return "CANCEL"; case KeyEvent.VK_CLEAR: return "CLEAR"; case KeyEvent.VK_SHIFT: return "SHIFT"; case KeyEvent.VK_CONTROL: return "CONTROL"; case KeyEvent.VK_ALT: return "ALT"; case KeyEvent.VK_PAUSE: return "PAUSE"; case KeyEvent.VK_CAPS_LOCK: return "CAPS_LOCK"; case KeyEvent.VK_ESCAPE: return "ESCAPE"; case KeyEvent.VK_SPACE: return "SPACE"; case KeyEvent.VK_PAGE_UP: return "PAGE_UP"; case KeyEvent.VK_PAGE_DOWN: return "PAGE_DOWN"; case KeyEvent.VK_END: return "END"; case KeyEvent.VK_HOME: return "HOME"; case KeyEvent.VK_LEFT: return "LEFT"; case KeyEvent.VK_UP: return "UP"; case KeyEvent.VK_RIGHT: return "RIGHT"; case KeyEvent.VK_DOWN: return "DOWN"; // numpad numeric keys handled below case KeyEvent.VK_MULTIPLY: return "MULTIPLY"; case KeyEvent.VK_ADD: return "ADD"; case KeyEvent.VK_SEPARATOR: return "SEPARATOR"; case KeyEvent.VK_SUBTRACT: return "SUBTRACT"; case KeyEvent.VK_DECIMAL: return "DECIMAL"; case KeyEvent.VK_DIVIDE: return "DIVIDE"; case KeyEvent.VK_DELETE: return "DELETE"; case KeyEvent.VK_NUM_LOCK: return "NUM_LOCK"; case KeyEvent.VK_SCROLL_LOCK: return "SCROLL_LOCK"; 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"; case KeyEvent.VK_F13: return "F13"; case KeyEvent.VK_F14: return "F14"; case KeyEvent.VK_F15: return "F15"; case KeyEvent.VK_F16: return "F16"; case KeyEvent.VK_F17: return "F17"; case KeyEvent.VK_F18: return "F18"; case KeyEvent.VK_F19: return "F19"; case KeyEvent.VK_F20: return "F20"; case KeyEvent.VK_F21: return "F21"; case KeyEvent.VK_F22: return "F22"; case KeyEvent.VK_F23: return "F23"; case KeyEvent.VK_F24: return "F24"; case KeyEvent.VK_PRINTSCREEN: return "PRINTSCREEN"; case KeyEvent.VK_INSERT: return "INSERT"; case KeyEvent.VK_HELP: return "HELP"; case KeyEvent.VK_META: return "META"; case KeyEvent.VK_BACK_QUOTE: return "BACK_QUOTE"; case KeyEvent.VK_QUOTE: return "QUOTE"; case KeyEvent.VK_KP_UP: return "KP_UP"; case KeyEvent.VK_KP_DOWN: return "KP_DOWN"; case KeyEvent.VK_KP_LEFT: return "KP_LEFT"; case KeyEvent.VK_KP_RIGHT: return "KP_RIGHT"; case KeyEvent.VK_DEAD_GRAVE: return "DEAD_GRAVE"; case KeyEvent.VK_DEAD_ACUTE: return "DEAD_ACUTE"; case KeyEvent.VK_DEAD_CIRCUMFLEX: return "DEAD_CIRCUMFLEX"; case KeyEvent.VK_DEAD_TILDE: return "DEAD_TILDE"; case KeyEvent.VK_DEAD_MACRON: return "DEAD_MACRON"; case KeyEvent.VK_DEAD_BREVE: return "DEAD_BREVE"; case KeyEvent.VK_DEAD_ABOVEDOT: return "DEAD_ABOVEDOT"; case KeyEvent.VK_DEAD_DIAERESIS: return "DEAD_DIAERESIS"; case KeyEvent.VK_DEAD_ABOVERING: return "DEAD_ABOVERING"; case KeyEvent.VK_DEAD_DOUBLEACUTE: return "DEAD_DOUBLEACUTE"; case KeyEvent.VK_DEAD_CARON: return "DEAD_CARON"; case KeyEvent.VK_DEAD_CEDILLA: return "DEAD_CEDILLA"; case KeyEvent.VK_DEAD_OGONEK: return "DEAD_OGONEK"; case KeyEvent.VK_DEAD_IOTA: return "DEAD_IOTA"; case KeyEvent.VK_DEAD_VOICED_SOUND: return "DEAD_VOICED_SOUND"; case KeyEvent.VK_DEAD_SEMIVOICED_SOUND: return "DEAD_SEMIVOICED_SOUND"; case KeyEvent.VK_AMPERSAND: return "AMPERSAND"; case KeyEvent.VK_ASTERISK: return "ASTERISK"; case KeyEvent.VK_QUOTEDBL: return "QUOTEDBL"; case KeyEvent.VK_LESS: return "LESS"; case KeyEvent.VK_GREATER: return "GREATER"; case KeyEvent.VK_BRACELEFT: return "BRACELEFT"; case KeyEvent.VK_BRACERIGHT: return "BRACERIGHT"; case KeyEvent.VK_AT: return "AT"; case KeyEvent.VK_COLON: return "COLON"; case KeyEvent.VK_CIRCUMFLEX: return "CIRCUMFLEX"; case KeyEvent.VK_DOLLAR: return "DOLLAR"; case KeyEvent.VK_EURO_SIGN: return "EURO_SIGN"; case KeyEvent.VK_EXCLAMATION_MARK: return "EXCLAMATION_MARK"; case KeyEvent.VK_INVERTED_EXCLAMATION_MARK: return "INVERTED_EXCLAMATION_MARK"; case KeyEvent.VK_LEFT_PARENTHESIS: return "LEFT_PARENTHESIS"; case KeyEvent.VK_NUMBER_SIGN: return "NUMBER_SIGN"; case KeyEvent.VK_MINUS: return "MINUS"; case KeyEvent.VK_PLUS: return "PLUS"; case KeyEvent.VK_RIGHT_PARENTHESIS: return "RIGHT_PARENTHESIS"; case KeyEvent.VK_UNDERSCORE: return "UNDERSCORE"; case KeyEvent.VK_FINAL: return "FINAL"; case KeyEvent.VK_CONVERT: return "CONVERT"; case KeyEvent.VK_NONCONVERT: return "NONCONVERT"; case KeyEvent.VK_ACCEPT: return "ACCEPT"; case KeyEvent.VK_MODECHANGE: return "MODECHANGE"; case KeyEvent.VK_KANA: return "KANA"; case KeyEvent.VK_KANJI: return "KANJI"; case KeyEvent.VK_ALPHANUMERIC: return "ALPHANUMERIC"; case KeyEvent.VK_KATAKANA: return "KATAKANA"; case KeyEvent.VK_HIRAGANA: return "HIRAGANA"; case KeyEvent.VK_FULL_WIDTH: return "FULL_WIDTH"; case KeyEvent.VK_HALF_WIDTH: return "HALF_WIDTH"; case KeyEvent.VK_ROMAN_CHARACTERS: return "ROMAN_CHARACTERS"; case KeyEvent.VK_ALL_CANDIDATES: return "ALL_CANDIDATES"; case KeyEvent.VK_PREVIOUS_CANDIDATE: return "PREVIOUS_CANDIDATE"; case KeyEvent.VK_CODE_INPUT: return "CODE_INPUT"; case KeyEvent.VK_JAPANESE_KATAKANA: return "JAPANESE_KATAKANA"; case KeyEvent.VK_JAPANESE_HIRAGANA: return "JAPANESE_HIRAGANA"; case KeyEvent.VK_JAPANESE_ROMAN: return "JAPANESE_ROMAN"; case KeyEvent.VK_KANA_LOCK: return "KANA_LOCK"; case KeyEvent.VK_INPUT_METHOD_ON_OFF: return "INPUT_METHOD_ON_OFF"; case KeyEvent.VK_AGAIN: return "AGAIN"; case KeyEvent.VK_UNDO: return "UNDO"; case KeyEvent.VK_COPY: return "COPY"; case KeyEvent.VK_PASTE: return "PASTE"; case KeyEvent.VK_CUT: return "CUT"; case KeyEvent.VK_FIND: return "FIND"; case KeyEvent.VK_PROPS: return "PROPS"; case KeyEvent.VK_STOP: return "STOP"; case KeyEvent.VK_COMPOSE: return "COMPOSE"; case KeyEvent.VK_ALT_GRAPH: return "ALT_GRAPH"; } if (keyCode >= KeyEvent.VK_NUMPAD0 && keyCode <= KeyEvent.VK_NUMPAD9) { char c = (char) (keyCode - KeyEvent.VK_NUMPAD0 + '0'); return "NUMPAD" + c; } return "unknown(0x" + Integer.toString(keyCode, 16) + ")"; }
From source file:Main.java
static String getKeyText(int keyCode) { if (keyCode >= KeyEvent.VK_0 && keyCode <= KeyEvent.VK_9 || keyCode >= KeyEvent.VK_A && keyCode <= KeyEvent.VK_Z) { return String.valueOf((char) keyCode); }/*from w ww . j a v a 2 s . c om*/ switch (keyCode) { case KeyEvent.VK_COMMA: return "COMMA"; case KeyEvent.VK_PERIOD: return "PERIOD"; case KeyEvent.VK_SLASH: return "SLASH"; case KeyEvent.VK_SEMICOLON: return "SEMICOLON"; case KeyEvent.VK_EQUALS: return "EQUALS"; case KeyEvent.VK_OPEN_BRACKET: return "OPEN_BRACKET"; case KeyEvent.VK_BACK_SLASH: return "BACK_SLASH"; case KeyEvent.VK_CLOSE_BRACKET: return "CLOSE_BRACKET"; case KeyEvent.VK_ENTER: return "ENTER"; case KeyEvent.VK_BACK_SPACE: return "BACK_SPACE"; case KeyEvent.VK_TAB: return "TAB"; case KeyEvent.VK_CANCEL: return "CANCEL"; case KeyEvent.VK_CLEAR: return "CLEAR"; case KeyEvent.VK_SHIFT: return "SHIFT"; case KeyEvent.VK_CONTROL: return "CONTROL"; case KeyEvent.VK_ALT: return "ALT"; case KeyEvent.VK_PAUSE: return "PAUSE"; case KeyEvent.VK_CAPS_LOCK: return "CAPS_LOCK"; case KeyEvent.VK_ESCAPE: return "ESCAPE"; case KeyEvent.VK_SPACE: return "SPACE"; case KeyEvent.VK_PAGE_UP: return "PAGE_UP"; case KeyEvent.VK_PAGE_DOWN: return "PAGE_DOWN"; case KeyEvent.VK_END: return "END"; case KeyEvent.VK_HOME: return "HOME"; case KeyEvent.VK_LEFT: return "LEFT"; case KeyEvent.VK_UP: return "UP"; case KeyEvent.VK_RIGHT: return "RIGHT"; case KeyEvent.VK_DOWN: return "DOWN"; case KeyEvent.VK_MULTIPLY: return "MULTIPLY"; case KeyEvent.VK_ADD: return "ADD"; case KeyEvent.VK_SEPARATOR: return "SEPARATOR"; case KeyEvent.VK_SUBTRACT: return "SUBTRACT"; case KeyEvent.VK_DECIMAL: return "DECIMAL"; case KeyEvent.VK_DIVIDE: return "DIVIDE"; case KeyEvent.VK_DELETE: return "DELETE"; case KeyEvent.VK_NUM_LOCK: return "NUM_LOCK"; case KeyEvent.VK_SCROLL_LOCK: return "SCROLL_LOCK"; 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"; case KeyEvent.VK_F13: return "F13"; case KeyEvent.VK_F14: return "F14"; case KeyEvent.VK_F15: return "F15"; case KeyEvent.VK_F16: return "F16"; case KeyEvent.VK_F17: return "F17"; case KeyEvent.VK_F18: return "F18"; case KeyEvent.VK_F19: return "F19"; case KeyEvent.VK_F20: return "F20"; case KeyEvent.VK_F21: return "F21"; case KeyEvent.VK_F22: return "F22"; case KeyEvent.VK_F23: return "F23"; case KeyEvent.VK_F24: return "F24"; case KeyEvent.VK_PRINTSCREEN: return "PRINTSCREEN"; case KeyEvent.VK_INSERT: return "INSERT"; case KeyEvent.VK_HELP: return "HELP"; case KeyEvent.VK_META: return "META"; case KeyEvent.VK_BACK_QUOTE: return "BACK_QUOTE"; case KeyEvent.VK_QUOTE: return "QUOTE"; case KeyEvent.VK_KP_UP: return "KP_UP"; case KeyEvent.VK_KP_DOWN: return "KP_DOWN"; case KeyEvent.VK_KP_LEFT: return "KP_LEFT"; case KeyEvent.VK_KP_RIGHT: return "KP_RIGHT"; case KeyEvent.VK_DEAD_GRAVE: return "DEAD_GRAVE"; case KeyEvent.VK_DEAD_ACUTE: return "DEAD_ACUTE"; case KeyEvent.VK_DEAD_CIRCUMFLEX: return "DEAD_CIRCUMFLEX"; case KeyEvent.VK_DEAD_TILDE: return "DEAD_TILDE"; case KeyEvent.VK_DEAD_MACRON: return "DEAD_MACRON"; case KeyEvent.VK_DEAD_BREVE: return "DEAD_BREVE"; case KeyEvent.VK_DEAD_ABOVEDOT: return "DEAD_ABOVEDOT"; case KeyEvent.VK_DEAD_DIAERESIS: return "DEAD_DIAERESIS"; case KeyEvent.VK_DEAD_ABOVERING: return "DEAD_ABOVERING"; case KeyEvent.VK_DEAD_DOUBLEACUTE: return "DEAD_DOUBLEACUTE"; case KeyEvent.VK_DEAD_CARON: return "DEAD_CARON"; case KeyEvent.VK_DEAD_CEDILLA: return "DEAD_CEDILLA"; case KeyEvent.VK_DEAD_OGONEK: return "DEAD_OGONEK"; case KeyEvent.VK_DEAD_IOTA: return "DEAD_IOTA"; case KeyEvent.VK_DEAD_VOICED_SOUND: return "DEAD_VOICED_SOUND"; case KeyEvent.VK_DEAD_SEMIVOICED_SOUND: return "DEAD_SEMIVOICED_SOUND"; case KeyEvent.VK_AMPERSAND: return "AMPERSAND"; case KeyEvent.VK_ASTERISK: return "ASTERISK"; case KeyEvent.VK_QUOTEDBL: return "QUOTEDBL"; case KeyEvent.VK_LESS: return "LESS"; case KeyEvent.VK_GREATER: return "GREATER"; case KeyEvent.VK_BRACELEFT: return "BRACELEFT"; case KeyEvent.VK_BRACERIGHT: return "BRACERIGHT"; case KeyEvent.VK_AT: return "AT"; case KeyEvent.VK_COLON: return "COLON"; case KeyEvent.VK_CIRCUMFLEX: return "CIRCUMFLEX"; case KeyEvent.VK_DOLLAR: return "DOLLAR"; case KeyEvent.VK_EURO_SIGN: return "EURO_SIGN"; case KeyEvent.VK_EXCLAMATION_MARK: return "EXCLAMATION_MARK"; case KeyEvent.VK_INVERTED_EXCLAMATION_MARK: return "INVERTED_EXCLAMATION_MARK"; case KeyEvent.VK_LEFT_PARENTHESIS: return "LEFT_PARENTHESIS"; case KeyEvent.VK_NUMBER_SIGN: return "NUMBER_SIGN"; case KeyEvent.VK_MINUS: return "MINUS"; case KeyEvent.VK_PLUS: return "PLUS"; case KeyEvent.VK_RIGHT_PARENTHESIS: return "RIGHT_PARENTHESIS"; case KeyEvent.VK_UNDERSCORE: return "UNDERSCORE"; case KeyEvent.VK_FINAL: return "FINAL"; case KeyEvent.VK_CONVERT: return "CONVERT"; case KeyEvent.VK_NONCONVERT: return "NONCONVERT"; case KeyEvent.VK_ACCEPT: return "ACCEPT"; case KeyEvent.VK_MODECHANGE: return "MODECHANGE"; case KeyEvent.VK_KANA: return "KANA"; case KeyEvent.VK_KANJI: return "KANJI"; case KeyEvent.VK_ALPHANUMERIC: return "ALPHANUMERIC"; case KeyEvent.VK_KATAKANA: return "KATAKANA"; case KeyEvent.VK_HIRAGANA: return "HIRAGANA"; case KeyEvent.VK_FULL_WIDTH: return "FULL_WIDTH"; case KeyEvent.VK_HALF_WIDTH: return "HALF_WIDTH"; case KeyEvent.VK_ROMAN_CHARACTERS: return "ROMAN_CHARACTERS"; case KeyEvent.VK_ALL_CANDIDATES: return "ALL_CANDIDATES"; case KeyEvent.VK_PREVIOUS_CANDIDATE: return "PREVIOUS_CANDIDATE"; case KeyEvent.VK_CODE_INPUT: return "CODE_INPUT"; case KeyEvent.VK_JAPANESE_KATAKANA: return "JAPANESE_KATAKANA"; case KeyEvent.VK_JAPANESE_HIRAGANA: return "JAPANESE_HIRAGANA"; case KeyEvent.VK_JAPANESE_ROMAN: return "JAPANESE_ROMAN"; case KeyEvent.VK_KANA_LOCK: return "KANA_LOCK"; case KeyEvent.VK_INPUT_METHOD_ON_OFF: return "INPUT_METHOD_ON_OFF"; case KeyEvent.VK_AGAIN: return "AGAIN"; case KeyEvent.VK_UNDO: return "UNDO"; case KeyEvent.VK_COPY: return "COPY"; case KeyEvent.VK_PASTE: return "PASTE"; case KeyEvent.VK_CUT: return "CUT"; case KeyEvent.VK_FIND: return "FIND"; case KeyEvent.VK_PROPS: return "PROPS"; case KeyEvent.VK_STOP: return "STOP"; case KeyEvent.VK_COMPOSE: return "COMPOSE"; case KeyEvent.VK_ALT_GRAPH: return "ALT_GRAPH"; } if (keyCode >= KeyEvent.VK_NUMPAD0 && keyCode <= KeyEvent.VK_NUMPAD9) { char c = (char) (keyCode - KeyEvent.VK_NUMPAD0 + '0'); return "NUMPAD" + c; } return "unknown(0x" + Integer.toString(keyCode, 16) + ")"; }
From source file:Main.java
static String getKeyText(int keyCode) { if (keyCode >= KeyEvent.VK_0 && keyCode <= KeyEvent.VK_9 || keyCode >= KeyEvent.VK_A && keyCode <= KeyEvent.VK_Z) { return String.valueOf((char) keyCode); }//from w w w . j a v a 2s .c o m switch (keyCode) { case KeyEvent.VK_COMMA: return "COMMA"; case KeyEvent.VK_PERIOD: return "PERIOD"; case KeyEvent.VK_SLASH: return "SLASH"; case KeyEvent.VK_SEMICOLON: return "SEMICOLON"; case KeyEvent.VK_EQUALS: return "EQUALS"; case KeyEvent.VK_OPEN_BRACKET: return "OPEN_BRACKET"; case KeyEvent.VK_BACK_SLASH: return "BACK_SLASH"; case KeyEvent.VK_CLOSE_BRACKET: return "CLOSE_BRACKET"; case KeyEvent.VK_ENTER: return "ENTER"; case KeyEvent.VK_BACK_SPACE: return "BACK_SPACE"; case KeyEvent.VK_TAB: return "TAB"; case KeyEvent.VK_CANCEL: return "CANCEL"; case KeyEvent.VK_CLEAR: return "CLEAR"; case KeyEvent.VK_SHIFT: return "SHIFT"; case KeyEvent.VK_CONTROL: return "CONTROL"; case KeyEvent.VK_ALT: return "ALT"; case KeyEvent.VK_PAUSE: return "PAUSE"; case KeyEvent.VK_CAPS_LOCK: return "CAPS_LOCK"; case KeyEvent.VK_ESCAPE: return "ESCAPE"; case KeyEvent.VK_SPACE: return "SPACE"; case KeyEvent.VK_PAGE_UP: return "PAGE_UP"; case KeyEvent.VK_PAGE_DOWN: return "PAGE_DOWN"; case KeyEvent.VK_END: return "END"; case KeyEvent.VK_HOME: return "HOME"; case KeyEvent.VK_LEFT: return "LEFT"; case KeyEvent.VK_UP: return "UP"; case KeyEvent.VK_RIGHT: return "RIGHT"; case KeyEvent.VK_DOWN: return "DOWN"; // numpad numeric keys handled below case KeyEvent.VK_MULTIPLY: return "MULTIPLY"; case KeyEvent.VK_ADD: return "ADD"; case KeyEvent.VK_SEPARATOR: return "SEPARATOR"; case KeyEvent.VK_SUBTRACT: return "SUBTRACT"; case KeyEvent.VK_DECIMAL: return "DECIMAL"; case KeyEvent.VK_DIVIDE: return "DIVIDE"; case KeyEvent.VK_DELETE: return "DELETE"; case KeyEvent.VK_NUM_LOCK: return "NUM_LOCK"; case KeyEvent.VK_SCROLL_LOCK: return "SCROLL_LOCK"; 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"; case KeyEvent.VK_F13: return "F13"; case KeyEvent.VK_F14: return "F14"; case KeyEvent.VK_F15: return "F15"; case KeyEvent.VK_F16: return "F16"; case KeyEvent.VK_F17: return "F17"; case KeyEvent.VK_F18: return "F18"; case KeyEvent.VK_F19: return "F19"; case KeyEvent.VK_F20: return "F20"; case KeyEvent.VK_F21: return "F21"; case KeyEvent.VK_F22: return "F22"; case KeyEvent.VK_F23: return "F23"; case KeyEvent.VK_F24: return "F24"; case KeyEvent.VK_PRINTSCREEN: return "PRINTSCREEN"; case KeyEvent.VK_INSERT: return "INSERT"; case KeyEvent.VK_HELP: return "HELP"; case KeyEvent.VK_META: return "META"; case KeyEvent.VK_BACK_QUOTE: return "BACK_QUOTE"; case KeyEvent.VK_QUOTE: return "QUOTE"; case KeyEvent.VK_KP_UP: return "KP_UP"; case KeyEvent.VK_KP_DOWN: return "KP_DOWN"; case KeyEvent.VK_KP_LEFT: return "KP_LEFT"; case KeyEvent.VK_KP_RIGHT: return "KP_RIGHT"; case KeyEvent.VK_DEAD_GRAVE: return "DEAD_GRAVE"; case KeyEvent.VK_DEAD_ACUTE: return "DEAD_ACUTE"; case KeyEvent.VK_DEAD_CIRCUMFLEX: return "DEAD_CIRCUMFLEX"; case KeyEvent.VK_DEAD_TILDE: return "DEAD_TILDE"; case KeyEvent.VK_DEAD_MACRON: return "DEAD_MACRON"; case KeyEvent.VK_DEAD_BREVE: return "DEAD_BREVE"; case KeyEvent.VK_DEAD_ABOVEDOT: return "DEAD_ABOVEDOT"; case KeyEvent.VK_DEAD_DIAERESIS: return "DEAD_DIAERESIS"; case KeyEvent.VK_DEAD_ABOVERING: return "DEAD_ABOVERING"; case KeyEvent.VK_DEAD_DOUBLEACUTE: return "DEAD_DOUBLEACUTE"; case KeyEvent.VK_DEAD_CARON: return "DEAD_CARON"; case KeyEvent.VK_DEAD_CEDILLA: return "DEAD_CEDILLA"; case KeyEvent.VK_DEAD_OGONEK: return "DEAD_OGONEK"; case KeyEvent.VK_DEAD_IOTA: return "DEAD_IOTA"; case KeyEvent.VK_DEAD_VOICED_SOUND: return "DEAD_VOICED_SOUND"; case KeyEvent.VK_DEAD_SEMIVOICED_SOUND: return "DEAD_SEMIVOICED_SOUND"; case KeyEvent.VK_AMPERSAND: return "AMPERSAND"; case KeyEvent.VK_ASTERISK: return "ASTERISK"; case KeyEvent.VK_QUOTEDBL: return "QUOTEDBL"; case KeyEvent.VK_LESS: return "LESS"; case KeyEvent.VK_GREATER: return "GREATER"; case KeyEvent.VK_BRACELEFT: return "BRACELEFT"; case KeyEvent.VK_BRACERIGHT: return "BRACERIGHT"; case KeyEvent.VK_AT: return "AT"; case KeyEvent.VK_COLON: return "COLON"; case KeyEvent.VK_CIRCUMFLEX: return "CIRCUMFLEX"; case KeyEvent.VK_DOLLAR: return "DOLLAR"; case KeyEvent.VK_EURO_SIGN: return "EURO_SIGN"; case KeyEvent.VK_EXCLAMATION_MARK: return "EXCLAMATION_MARK"; case KeyEvent.VK_INVERTED_EXCLAMATION_MARK: return "INVERTED_EXCLAMATION_MARK"; case KeyEvent.VK_LEFT_PARENTHESIS: return "LEFT_PARENTHESIS"; case KeyEvent.VK_NUMBER_SIGN: return "NUMBER_SIGN"; case KeyEvent.VK_MINUS: return "MINUS"; case KeyEvent.VK_PLUS: return "PLUS"; case KeyEvent.VK_RIGHT_PARENTHESIS: return "RIGHT_PARENTHESIS"; case KeyEvent.VK_UNDERSCORE: return "UNDERSCORE"; case KeyEvent.VK_FINAL: return "FINAL"; case KeyEvent.VK_CONVERT: return "CONVERT"; case KeyEvent.VK_NONCONVERT: return "NONCONVERT"; case KeyEvent.VK_ACCEPT: return "ACCEPT"; case KeyEvent.VK_MODECHANGE: return "MODECHANGE"; case KeyEvent.VK_KANA: return "KANA"; case KeyEvent.VK_KANJI: return "KANJI"; case KeyEvent.VK_ALPHANUMERIC: return "ALPHANUMERIC"; case KeyEvent.VK_KATAKANA: return "KATAKANA"; case KeyEvent.VK_HIRAGANA: return "HIRAGANA"; case KeyEvent.VK_FULL_WIDTH: return "FULL_WIDTH"; case KeyEvent.VK_HALF_WIDTH: return "HALF_WIDTH"; case KeyEvent.VK_ROMAN_CHARACTERS: return "ROMAN_CHARACTERS"; case KeyEvent.VK_ALL_CANDIDATES: return "ALL_CANDIDATES"; case KeyEvent.VK_PREVIOUS_CANDIDATE: return "PREVIOUS_CANDIDATE"; case KeyEvent.VK_CODE_INPUT: return "CODE_INPUT"; case KeyEvent.VK_JAPANESE_KATAKANA: return "JAPANESE_KATAKANA"; case KeyEvent.VK_JAPANESE_HIRAGANA: return "JAPANESE_HIRAGANA"; case KeyEvent.VK_JAPANESE_ROMAN: return "JAPANESE_ROMAN"; case KeyEvent.VK_KANA_LOCK: return "KANA_LOCK"; case KeyEvent.VK_INPUT_METHOD_ON_OFF: return "INPUT_METHOD_ON_OFF"; case KeyEvent.VK_AGAIN: return "AGAIN"; case KeyEvent.VK_UNDO: return "UNDO"; case KeyEvent.VK_COPY: return "COPY"; case KeyEvent.VK_PASTE: return "PASTE"; case KeyEvent.VK_CUT: return "CUT"; case KeyEvent.VK_FIND: return "FIND"; case KeyEvent.VK_PROPS: return "PROPS"; case KeyEvent.VK_STOP: return "STOP"; case KeyEvent.VK_COMPOSE: return "COMPOSE"; case KeyEvent.VK_ALT_GRAPH: return "ALT_GRAPH"; } if (keyCode >= KeyEvent.VK_NUMPAD0 && keyCode <= KeyEvent.VK_NUMPAD9) { char c = (char) (keyCode - KeyEvent.VK_NUMPAD0 + '0'); return "NUMPAD" + c; } return "unknown(0x" + Integer.toString(keyCode, 16) + ")"; }
From source file:net.sf.firemox.DeckBuilder.java
/** * Creates new form DeckBuilder/*from w w w . jav a2 s. co m*/ */ private DeckBuilder() { super("DeckBuilder"); form = this; timerPanel = new TimerGlassPane(); cardLoader = new CardLoader(timerPanel); timer = new Timer(200, cardLoader); setGlassPane(timerPanel); try { setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif")); } catch (Exception e) { // IGNORING } // Load settings loadSettings(); // Initialize components final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this); newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK)); final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this); loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this); saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0)); final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this); quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK)); final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this); deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this); aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK)); final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this); final JMenu mainMenu = UIHelper.buildMenu("menu_file"); mainMenu.add(newItem); mainMenu.add(loadItem); mainMenu.add(saveAsItem); mainMenu.add(saveItem); mainMenu.add(new JSeparator()); mainMenu.add(quitItem); super.optionMenu = new JMenu("Options"); final JMenu convertMenu = UIHelper.buildMenu("menu_convert"); convertMenu.add(convertDCK); final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this); helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); final JMenu helpMenu = new JMenu("?"); helpMenu.add(helpItem); helpMenu.add(deckConstraintsItem); helpMenu.add(aboutItem); final JMenuBar menuBar = new JMenuBar(); menuBar.add(mainMenu); initAbstractMenu(); menuBar.add(optionMenu); menuBar.add(convertMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); addWindowListener(this); // Build the panel containing amount of available cards final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT); // Build the left list allListModel = new MListModel<MCardCompare>(amountLeft, false); leftList = new ThreadSafeJList(allListModel); leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); leftList.setLayoutOrientation(JList.VERTICAL); leftList.getSelectionModel().addListSelectionListener(this); leftList.addMouseListener(this); leftList.setVisibleRowCount(10); // Initialize the text field containing the amount to add addQtyTxt = new JTextField("1"); // Build the "Add" button addButton = new JButton(LanguageManager.getString("db_add")); addButton.setMnemonic('a'); addButton.setEnabled(false); // Build the panel containing : "Add" amount and "Add" button final Box addPanel = Box.createHorizontalBox(); addPanel.add(addButton); addPanel.add(addQtyTxt); addPanel.setMaximumSize(new Dimension(32010, 26)); // Build the panel containing the selected card name cardNameTxt = new JTextField(); new HireListener(cardNameTxt, addButton, this, leftList); final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : "); searchLabel.setLabelFor(cardNameTxt); // Build the panel containing search label and card name text field final Box searchPanel = Box.createHorizontalBox(); searchPanel.add(searchLabel); searchPanel.add(cardNameTxt); searchPanel.setMaximumSize(new Dimension(32010, 26)); listScrollerLeft = new JScrollPane(leftList); MToolKit.addOverlay(listScrollerLeft); // Build the left panel containing : list, available amount, "Add" panel final JPanel srcPanel = new JPanel(null); srcPanel.add(searchPanel); srcPanel.add(listScrollerLeft); srcPanel.add(amountLeft); srcPanel.add(addPanel); srcPanel.setMinimumSize(new Dimension(220, 200)); srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS)); // Initialize constraints constraintsChecker = new ConstraintsChecker(); constraintsChecker.setBorder(new EtchedBorder()); final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker); MToolKit.addOverlay(constraintsCheckerScroll); // create a pane with the oracle text for the present card oracleText = new JLabel(); oracleText.setPreferredSize(new Dimension(180, 200)); oracleText.setVerticalAlignment(SwingConstants.TOP); final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(oracle); // build some Pie Charts and a panel to display it initSets(); datasets = new ChartSets(); final JTabbedPane tabbedPane = new JTabbedPane(); for (ChartFilter filter : ChartFilter.values()) { final Dataset dataSet = filter.createDataSet(this); final JFreeChart chart = new JFreeChart(null, null, filter.createPlot(dataSet, painterMapper.get(filter)), false); datasets.addDataSet(filter, dataSet); ChartPanel pieChartPanel = new ChartPanel(chart, true); tabbedPane.add(pieChartPanel, filter.getTitle()); } // add the Constraints scroll panel and Oracle text Pane to the tabbedPane tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints")); tabbedPane.add(oracle, LanguageManager.getString("db_text")); tabbedPane.setSelectedComponent(oracle); // The toollBar for color filtering toolBar = new JToolBar(); toolBar.setFloatable(false); final JButton clearButton = UIHelper.buildButton("clear"); clearButton.addActionListener(this); toolBar.add(clearButton); final JToggleButton toggleColorlessButton = new JToggleButton( UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true); toggleColorlessButton.setActionCommand("0"); toggleColorlessButton.addActionListener(this); toolBar.add(toggleColorlessButton); for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) { final JToggleButton toggleButton = new JToggleButton( UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true); toggleButton.setActionCommand(String.valueOf(index)); toggleButton.addActionListener(this); toolBar.add(toggleButton); } // sorted card type combobox creation final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames)); Collections.sort(idCards); final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") }, idCards.toArray()); idCardComboBox = new JComboBox(cardTypes); idCardComboBox.setSelectedIndex(0); idCardComboBox.addActionListener(this); idCardComboBox.setActionCommand("cardTypeFilter"); // sorted card properties combobox creation final List<String> properties = new ArrayList<String>( CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty())); Collections.sort(properties); final Object[] cardProperties = ArrayUtils .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray()); propertiesComboBox = new JComboBox(cardProperties); propertiesComboBox.setSelectedIndex(0); propertiesComboBox.addActionListener(this); propertiesComboBox.setActionCommand("propertyFilter"); final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : "); final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : "); final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : "); // filter Panel with colors toolBar and card type combobox final Box filterPanel = Box.createHorizontalBox(); filterPanel.add(colors); filterPanel.add(toolBar); filterPanel.add(types); filterPanel.add(idCardComboBox); filterPanel.add(property); filterPanel.add(propertiesComboBox); getContentPane().add(filterPanel, BorderLayout.NORTH); // Destination section : // Build the panel containing amount of available cards final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT); rightAmount.setMaximumSize(new Dimension(220, 26)); // Build the right list rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true)); rightListModel.addTableModelListener(this); rightList = new JTable(rightListModel); rightList.setShowGrid(false); rightList.setTableHeader(null); rightList.getSelectionModel().addListSelectionListener(this); rightList.getColumnModel().getColumn(0).setMaxWidth(25); rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); // Build the panel containing the selected deck deckNameTxt = new JTextField("loading..."); deckNameTxt.setEditable(false); deckNameTxt.setBorder(null); final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : "); deckLabel.setLabelFor(deckNameTxt); final Box deckNamePanel = Box.createHorizontalBox(); deckNamePanel.add(deckLabel); deckNamePanel.add(deckNameTxt); deckNamePanel.setMaximumSize(new Dimension(220, 26)); // Initialize the text field containing the amount to remove removeQtyTxt = new JTextField("1"); // Build the "Remove" button removeButton = new JButton(LanguageManager.getString("db_remove")); removeButton.setMnemonic('r'); removeButton.addMouseListener(this); removeButton.setEnabled(false); // Build the panel containing : "Remove" amount and "Remove" button final Box removePanel = Box.createHorizontalBox(); removePanel.add(removeButton); removePanel.add(removeQtyTxt); removePanel.setMaximumSize(new Dimension(220, 26)); // Build the right panel containing : list, available amount, constraints final JScrollPane deskListScroller = new JScrollPane(rightList); MToolKit.addOverlay(deskListScroller); deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY)); deskListScroller.setMinimumSize(new Dimension(220, 200)); deskListScroller.setMaximumSize(new Dimension(220, 32000)); final Box destPanel = Box.createVerticalBox(); destPanel.add(deckNamePanel); destPanel.add(deskListScroller); destPanel.add(rightAmount); destPanel.add(removePanel); destPanel.setMinimumSize(new Dimension(220, 200)); destPanel.setMaximumSize(new Dimension(220, 32000)); // Build the panel containing the name of card in picture cardPictureNameTxt = new JLabel("<html><i>no selected card</i>"); final Box cardPictureNamePanel = Box.createHorizontalBox(); cardPictureNamePanel.add(cardPictureNameTxt); cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26)); // Group the detail panels final JPanel viewCard = new JPanel(null); viewCard.add(cardPictureNamePanel); viewCard.add(CardView.getInstance()); viewCard.add(tabbedPane); viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS)); final Box mainPanel = Box.createHorizontalBox(); mainPanel.add(destPanel); mainPanel.add(viewCard); // Add the main panel getContentPane().add(srcPanel, BorderLayout.WEST); getContentPane().add(mainPanel, BorderLayout.CENTER); // Size this frame getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT)); getRootPane().setMinimumSize(getRootPane().getPreferredSize()); pack(); }
From source file:es.darkhogg.hazelnutt.EditorFrame.java
private void initializeGui() { setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(100, 100, 640, 480);//from w w w.jav a 2 s . c om addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { actionExit(); } }); fileChooser = new JFileChooser(); //fileChooser.setFileFilter( hlfFileFilter ); hlfFileChooser = new JFileChooser(); hlfFileChooser.setFileFilter(hlfFileFilter); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('F'); menuBar.add(mnFile); menuLoadRom = new JMenuItem("Load ROM..."); menuLoadRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); menuLoadRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionOpenRom(null); } }); menuLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png"))); menuLoadRom.setMnemonic('O'); mnFile.add(menuLoadRom); menuSaveRom = new JMenuItem("Save ROM"); menuSaveRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRom(); } }); menuSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png"))); menuSaveRom.setMnemonic('S'); menuSaveRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); mnFile.add(menuSaveRom); menuSaveRomAs = new JMenuItem("Save ROM As..."); menuSaveRomAs.setMnemonic('a'); menuSaveRomAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK)); menuSaveRomAs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRomAs(); } }); menuSaveRomAs .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_as.png"))); mnFile.add(menuSaveRomAs); mnFile.addSeparator(); menuLoadLevel = new JMenuItem("Load Level..."); menuLoadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); menuLoadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionLoadLevel(); } }); menuLoadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png"))); menuLoadLevel.setMnemonic('L'); mnFile.add(menuLoadLevel); menuReloadLevel = new JMenuItem("Reload Level"); menuReloadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0)); menuReloadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionReloadLevel(); } }); menuReloadLevel.setMnemonic('R'); menuReloadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png"))); mnFile.add(menuReloadLevel); menuSaveLevel = new JMenuItem("Save Level"); menuSaveLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0)); menuSaveLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveLevel(); } }); menuSaveLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png"))); menuSaveLevel.setMnemonic('v'); mnFile.add(menuSaveLevel); //* mnFile.addSeparator(); menuImportLevel = new JMenuItem("Import Level..."); menuImportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)); menuImportLevel.setMnemonic('i'); menuImportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionImportLevel(); } }); menuImportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png"))); mnFile.add(menuImportLevel); menuExportLevel = new JMenuItem("Export Level..."); menuExportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); menuExportLevel.setMnemonic('e'); menuExportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionExportLevel(); } }); menuExportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png"))); mnFile.add(menuExportLevel); //*/ mnFile.addSeparator(); menuExit = new JMenuItem("Exit"); menuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); menuExit.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_exit.png"))); menuExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { actionExit(); } }); menuRecentFiles = new JMenu("Recent Files..."); mnFile.add(menuRecentFiles); mnFile.addSeparator(); menuExit.setMnemonic('X'); mnFile.add(menuExit); JMenu mnEdit = new JMenu("Edit"); mnEdit.setMnemonic('E'); menuBar.add(mnEdit); menuViewSpawn = new JCheckBoxMenuItem("View Spawn Point"); menuViewSpawn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0)); menuViewSpawn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuClearLevel = new JMenuItem("Clear Level"); menuClearLevel.setMnemonic('c'); menuClearLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); menuClearLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionClearLevel(); } }); menuClearLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png"))); mnEdit.add(menuClearLevel); mnEdit.addSeparator(); menuViewSpawn .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png"))); menuViewSpawn.setMnemonic('S'); menuViewSpawn.setSelected(true); mnEdit.add(menuViewSpawn); menuViewItems = new JCheckBoxMenuItem("View Items"); menuViewItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0)); menuViewItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewItems.setSelected(true); menuViewItems .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png"))); menuViewItems.setMnemonic('I'); mnEdit.add(menuViewItems); menuViewDoorItems = new JCheckBoxMenuItem("View Door Items"); menuViewDoorItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0)); menuViewDoorItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewDoorItems.setSelected(true); menuViewDoorItems.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png"))); menuViewDoorItems.setMnemonic('D'); mnEdit.add(menuViewDoorItems); menuViewEnemies = new JCheckBoxMenuItem("View Enemies"); menuViewEnemies.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0)); menuViewEnemies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewEnemies.setSelected(true); menuViewEnemies .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png"))); menuViewEnemies.setMnemonic('E'); mnEdit.add(menuViewEnemies); menuViewTypes = new JCheckBoxMenuItem("View Combo Types"); menuViewTypes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_5, 0)); menuViewTypes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewTypes.setSelected(true); menuViewTypes.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png"))); menuViewTypes.setMnemonic('C'); mnEdit.add(menuViewTypes); mnEdit.addSeparator(); scaleMenuItem = new JCheckBoxMenuItem("Scale Level Display"); scaleMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_6, 0)); scaleMenuItem.setMnemonic('l'); scaleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionScale(false); } }); scaleMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png"))); mnEdit.add(scaleMenuItem); gridMenuItem = new JCheckBoxMenuItem("Display grid"); gridMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_7, 0)); gridMenuItem.setMnemonic('G'); gridMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionGrid(false); } }); gridMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png"))); mnEdit.add(gridMenuItem); //mnEdit.addSeparator(); mntmPreferences = new JMenuItem("Preferences..."); mntmPreferences.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionPreferences(); } }); mntmPreferences.setMnemonic('P'); mntmPreferences.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_preferences.png"))); //mnEdit.add(mntmPreferences); mnHelp = new JMenu("Help"); mnHelp.setMnemonic('H'); menuBar.add(mnHelp); mntmCheckUpdates = new JMenuItem("Check for Updates..."); mntmCheckUpdates.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK)); mntmCheckUpdates.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionCheckUpdates(); } }); mntmCheckUpdates.setMnemonic('c'); mntmCheckUpdates .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_update.png"))); mnHelp.add(mntmCheckUpdates); mntmAbout = new JMenuItem("Readme..."); mntmAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); mntmAbout.setMnemonic('r'); mntmAbout.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/about.png"))); mntmAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionAbout(); } }); mnHelp.addSeparator(); mnHelp.add(mntmAbout); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); toolBar.setFloatable(false); contentPane.add(toolBar, BorderLayout.NORTH); barLoadRom = new JButton(""); barLoadRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionOpenRom(null); } }); barLoadRom.setToolTipText("Open"); barLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png"))); toolBar.add(barLoadRom); barSaveRom = new JButton(""); barSaveRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRom(); } }); barSaveRom.setToolTipText("Save"); barSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png"))); toolBar.add(barSaveRom); toolBar.addSeparator(); barImportLevel = new JButton(""); barImportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionImportLevel(); } }); barImportLevel.setToolTipText("Import Level"); barImportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png"))); toolBar.add(barImportLevel); barExportLevel = new JButton(""); barExportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionExportLevel(); } }); barExportLevel.setToolTipText("Export Level"); barExportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png"))); toolBar.add(barExportLevel); toolBar.addSeparator(); barLoadLevel = new JButton(""); barLoadLevel.setToolTipText("Load Level"); barLoadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionLoadLevel(); } }); barLoadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png"))); toolBar.add(barLoadLevel); barReloadLevel = new JButton(""); barReloadLevel.setToolTipText("Reload Current Level"); barReloadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionReloadLevel(); } }); barReloadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png"))); toolBar.add(barReloadLevel); barSaveLevel = new JButton(""); barSaveLevel.setToolTipText("Save Level"); barSaveLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveLevel(); } }); barSaveLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png"))); toolBar.add(barSaveLevel); toolBar.addSeparator(); barViewItems = new JToggleButton(""); barViewItems.setToolTipText("Toggle View Items"); barViewItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewSpawn = new JToggleButton(""); barViewSpawn.setToolTipText("Toggle View Spawn"); barViewSpawn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barClearLevel = new JButton(""); barClearLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionClearLevel(); } }); barClearLevel.setToolTipText("Clear Level"); barClearLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png"))); toolBar.add(barClearLevel); toolBar.addSeparator(); barViewSpawn.setSelected(true); barViewSpawn.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png"))); toolBar.add(barViewSpawn); barViewItems.setSelected(true); barViewItems.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png"))); toolBar.add(barViewItems); barViewDoorItems = new JToggleButton(""); barViewDoorItems.setToolTipText("Toggle View Door Items"); barViewDoorItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewDoorItems.setSelected(true); barViewDoorItems.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png"))); toolBar.add(barViewDoorItems); barViewEnemies = new JToggleButton(""); barViewEnemies.setToolTipText("toggle View Enemies"); barViewEnemies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewEnemies.setSelected(true); barViewEnemies .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png"))); toolBar.add(barViewEnemies); barViewTypes = new JToggleButton(""); barViewTypes.setToolTipText("Toggle view Combo Help"); barViewTypes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewTypes.setSelected(true); barViewTypes.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png"))); toolBar.add(barViewTypes); barViewSpawn.setSelected(config.getBoolean("Hazelnutt.gui.viewSpawn", true)); barViewItems.setSelected(config.getBoolean("Hazelnutt.gui.viewItems", true)); barViewDoorItems.setSelected(config.getBoolean("Hazelnutt.gui.viewDoorItems", true)); barViewEnemies.setSelected(config.getBoolean("Hazelnutt.gui.viewEnemies", true)); barViewTypes.setSelected(config.getBoolean("Hazelnutt.gui.viewHelp", true)); panel = new JPanel(); contentPane.add(panel, BorderLayout.EAST); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); selectorPanel = new SelectorPanel(); selectorPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Combo & Entity Selector", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); panel.add(selectorPanel); propertiesPanel = new PropertiesPanel(null); propertiesPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level Properties", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); panel.add(propertiesPanel); toolBar.addSeparator(); scaleButton = new JToggleButton(""); scaleButton.setToolTipText("Toggle Scale Display"); scaleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionScale(true); } }); scaleButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png"))); toolBar.add(scaleButton); scaleButton.setSelected(config.getBoolean("Hazelnutt.gui.scaled", false)); gridButton = new JToggleButton(""); gridButton.setToolTipText("Display Grid"); gridButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionGrid(true); } }); gridButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png"))); toolBar.add(gridButton); gridButton.setSelected(config.getBoolean("Hazelnutt.gui.grid", false)); Component horizontalGlue = Box.createHorizontalGlue(); toolBar.add(horizontalGlue); Component verticalGlue = Box.createVerticalGlue(); panel.add(verticalGlue); levelWrapper = new JPanel(); levelWrapper.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); contentPane.add(levelWrapper, BorderLayout.CENTER); levelWrapper.setLayout(new BorderLayout(0, 0)); scrollPane = new JScrollPane(); scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); levelWrapper.add(scrollPane); levelDisplay = new LevelDisplay(); levelDisplay.addEditListener(new EditListener() { @Override public void leftPressed(int x, int y) { SelectionType st = selectorPanel.getSelectionType(); Object so = selectorPanel.getSelectedObject(); if (st == SelectionType.COMBO) { paintComboAt(x, y, ((Byte) so).byteValue()); } else if (st == SelectionType.SPAWN) { selectedLevel.getRomLevel().setSpawn(new IntVector(x, y)); levelHasChanged = true; } else if (st == SelectionType.ITEM) { Item ent = new Item((ItemType) so, x, y); EntityCollection<Item> ents = selectedLevel.getRomLevel().getItems(); for (Iterator<Item> it = ents.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } else if (st == SelectionType.DOOR_ITEM) { Item ent = new Item((ItemType) so, x, y); EntityCollection<Item> ents = selectedLevel.getRomLevel().getDoorItems(); for (Iterator<Item> it = ents.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } else if (st == SelectionType.ENEMY) { Enemy ent = new Enemy((EnemyType) so, x, y); EntityCollection<Enemy> ents = selectedLevel.getRomLevel().getEnemies(); for (Iterator<Enemy> it = ents.iterator(); it.hasNext();) { Enemy enem = it.next(); if (enem.getX() == x && enem.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } updateTitle(); levelDisplay.repaint(); levelHasChanged = true; } @Override public void centerPressed(int x, int y) { selectorPanel.forceComboSelection(selectedLevel.getRomLevel().getData()[x][y]); } @Override public void rightPressed(int x, int y) { deleteVisibleEntitiesAt(x, y); } @Override public void leftDragged(int x, int y) { if (selectorPanel.getSelectionType() == SelectionType.COMBO) { paintComboAt(x, y, ((Byte) selectorPanel.getSelectedObject()).byteValue()); } } @Override public void centerDragged(int x, int y) { // Nothing to de here } @Override public void rightDragged(int x, int y) { deleteVisibleEntitiesAt(x, y); } // Utility methods /*private void selectComboAt ( int x, int y ) { }/**/ private void paintComboAt(int x, int y, byte value) { selectedLevel.getRomLevel().getData()[x][y] = value; levelHasChanged = true; updateTitle(); levelDisplay.repaint(); } private void deleteVisibleEntitiesAt(int x, int y) { Collection<Item> items = selectedLevel.getRomLevel().getItems(); Collection<Item> doorItems = selectedLevel.getRomLevel().getDoorItems(); Collection<Enemy> enemies = selectedLevel.getRomLevel().getEnemies(); if (barViewItems.isSelected()) { for (Iterator<Item> it = items.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); levelHasChanged = true; } } } if (barViewDoorItems.isSelected()) { for (Iterator<Item> it = doorItems.iterator(); it.hasNext();) { Item doorItem = it.next(); if (doorItem.getX() == x && doorItem.getY() == y) { it.remove(); levelHasChanged = true; } } } if (barViewEnemies.isSelected()) { for (Iterator<Enemy> it = enemies.iterator(); it.hasNext();) { Enemy enem = it.next(); if (enem.getX() == x && enem.getY() == y) { it.remove(); levelHasChanged = true; } } } updateTitle(); levelDisplay.repaint(); } }); scrollPane.setViewportView(levelDisplay); updateTitle(); actionToggle(true); actionScale(true); actionGrid(true); setIconImage(Toolkit.getDefaultToolkit() .getImage(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/witch_hazel_big.png"))); setRomFeaturesEnabled(false); setLevelFeaturesEnabled(false); if (config.getBoolean("Hazelnutt.gui.maximum", false)) { setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); } else { int x = config.getInt("Hazelnutt.gui.location.x", Integer.MIN_VALUE); int y = config.getInt("Hazelnutt.gui.location.y", Integer.MIN_VALUE); int w = config.getInt("Hazelnutt.gui.size.width", Integer.MIN_VALUE); int h = config.getInt("Hazelnutt.gui.size.height", Integer.MIN_VALUE); if (x == Integer.MIN_VALUE || x == Integer.MIN_VALUE || w == Integer.MIN_VALUE || h == Integer.MIN_VALUE) { setLocationRelativeTo(null); } else { setLocation(x, y); setSize(w, h); } } propertiesPanel.addApplyListener(new PropertiesPanel.ApplyListener() { @Override public void apply() { levelHasChanged = true; updateTitle(); updateDisplay(); } }); if (config.containsKey("Hazelnutt.gui.lastDirectory")) { File lastDir = new File(config.getString("Hazelnutt.gui.lastDirectory")); if (lastDir.exists() && lastDir.isDirectory()) { //logger.debug( "Resetting the last directory: '" + lastDir + "'" ); fileChooser.setCurrentDirectory(lastDir); } } // Configure the PgUp and PgDn shortcuts InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PgUp"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PgDn"); ActionMap am = contentPane.getActionMap(); am.put("PgUp", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { actionLevelUp(); } }); am.put("PgDn", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { actionLevelDown(); } }); // Get the recent files recentFiles = new LinkedList<String>(Arrays.asList(config.getStringArray("Hazelnutt.gui.recentFiles"))); updateRecentFiles(); }