N Kumar
N Kumar

Reputation: 1312

Does Discarding Class Instance removes MouseListener

I have a class which implements MouseListner.
If i set this class instance to null will it remove MouseListener from the JPanel? or Do i have to manually remove MouseListening from JPanel using removeMouseListener

Upvotes: 0

Views: 32

Answers (2)

Breandán Dalton
Breandán Dalton

Reputation: 1639

You have only set your reference to the MouseListener to null. That means that you can't access the MouseListener through that variable, but the MouseListener itself still exists, so you must remove it from the JPanel using removeMouseListener.

Upvotes: 1

Atuos
Atuos

Reputation: 521

You have to remove the mouse listener.

Upvotes: 1

Related Questions