How to keep Java Swing action handler in one place? -


i writing swing interface multiple panels distributed in multiple classes. want implement mouse , key listener multiple of these panels. wander if there way keep user interaction in 1 place (possibly listener class).

my current code similar this:

class panel1 extends jpanel{     public panel1() {         addmouselistener(new mouselistener() {             @override             public void keypressed(keyevent e) {                 do_something();             }         });     }     void do_something(){         ...     } }  class panel2 extends jpanel{     public panel2() {         addmouselistener(new mouselistener() {             @override             public void keypressed(keyevent e) {                 different             }         });     } }  class panel3 ... 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -