I have subclassed MouseAdapter, and want to use it as both a MouseListener and a MouseMotionListener:
val ml: MouseListener = object : java.awt.event.MouseAdapter()
addMouseListener(ml)
// Not sure why need cast....
addMouseMotionListener(ml as MouseMotionListener)
Without the cast I have an error (Intellij)
Type mismatch.
Required:
MouseMotionListener!
Found:
MouseListener
(./gradlew build)
Type mismatch: inferred type is MouseListener but MouseMotionListener! was expected
EDIT: I should add that MouseAdapter implements both MouseListener and MouseMotionListener:
public abstract class MouseAdapter implements MouseListener, MouseWheelListener, MouseMotionListener {