java - a key listener that listen only special keys? -


my big problem codding game.i have 2 player in jframe can play cuncurrent. first player play arrow keys , second w/a/s/d keys..my instrutor said me achieve cuncurrent play should instantiate 2 thread every thread manage own special player..noe confuse how can have 2 thread tow players diffrence between them key listen...


another question maybe can me can have listener listen special keys??for exampe new listener listen w/s/a/d buttuns??(i familiar keyevent.getkeycode not mean because want listener never listen keys listen keys , in decision choose codder favorite key)

i infinitively greatfull if me.

you can define own keys processors (mainframe jframe instance)

actionmap actions = ((jcomponent)mainframe.getcontentpane()).getactionmap(); inputmap inputs = ((jcomponent)mainframe.getcontentpane()).getinputmap(jcomponent.when_ancestor_of_focused_component);  action a=new abstractaction() {     public void actionperformed(actionevent e) {         //call action code here     } }; actions.put("myaction", a);  inputs.put(keystroke.getkeystroke(keyevent.vk_enter, keyevent.ctrl_down_mask), "myaction"); 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -