user1420447
user1420447

Reputation: 35

Java change between several MouseListeners

I am working on an Drawing programm, which is using several MouseListeners. For example, I hava a class for drawing a line with a MouseListener and another one for drawing a circle. I start the MouseListener with a button and then validate() is called. Now I want to highlight a line or circle element, when the mouse is over the element. But I dont want to use a button for it. Instead after drawing an element the new Mouselistener for highlighting should start. But I dont know how to call validate() then. Or how to implement a MouseListener in a non static method.

Upvotes: 2

Views: 340

Answers (1)

Hidde
Hidde

Reputation: 11961

Use element.removeMouseListener(theListener) and add another Listener using element.addMouseListener(theOtheristener).

Upvotes: 3

Related Questions