Direct flow depending on incoming dynamic type

Posted by Improfane on Stack Overflow See other posts from Stack Overflow or by Improfane
Published on 2009-12-26T18:54:54Z Indexed on 2010/03/16 20:01 UTC
Read the original article Hit count: 219

Filed under:
|

I have a listener class that accepts GUI change events in one method.

The incoming event objects have a superclass of a type of GUI Event, the behaviour should depend on the dynamic type of the incoming variable.

I wanted to do do lots of methods like:

handleGUIEvent(EventChangedX event)
handleGUIEvent(EventChangedY event)

I am using a single event listener and receiving objects of various types but the behaviour should be different for each. What would you do?

I do not want to use a switch statement as this would get unmaintainable.

© Stack Overflow or respective owner

Related posts about java

Related posts about event-handling