Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //how to do action input map java
- InputMap imap = gameView.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
- ActionMap amap = gameView.getActionMap();
- {
- KeyStroke ks;
- EventEnum e;
- String en;
- Command c;
- ks = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0);
- e = EventEnum.gameClockTick;
- en = e.getOutputName();
- imap.put(ks, en);
- c = (Command)EventEnum.getActionFromEvent(e);
- amap.put(en, c);
- }
- InputMap imap = gameView.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
- ActionMap amap = gameView.getActionMap();
- {
- KeyStroke ks; //keystroke
- String n; //name
- Command c; //command
- ks = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0);
- n = "GameClockTick";
- imap.put(ks, n); //Places the keystroke as the key, and the name as the value.
- c = getCommandFromName(n); //returns the singleton command that is named variable n.
- amap.put(n, c); //Places the name as the key, and the command as the value.
- }
Advertisement
Add Comment
Please, Sign In to add comment