The idea of this code is the following: when user clicks on Move Tables button ActionListener should be removed and MouseMotionListener should be added , when the user clicks back on the Move Tables button it should add ActionListener back and remove MouseMotionListener.
I tried removeMouseMotionListener, but it does not work. I checked that the Move Tables button was working properly but still does not work.
Please tell me what Iam missing or what needs tro be done to remove MouseMotionListener
ArrayList<String> list = new ArrayList<String>();
As we would expect, the last line outputs "0". Now, look at this code:
ArrayList<Object> list = new ArrayList<Object>();
Here the last line outputs "1". The first object we added is still in the list. Why does that happen?
Well, to answer that, I will first explain why the first lines of code do work. In the second we implicitly create a new string "asdf" and in the third line we create another string "asdf". So we have two different strings with the same character sequences. So how does ArrayList find the correct string to remove? It calls equals(stringToRemove) on all its objects, until it finds an object for which it evaluates to true, and removes it.
Now it is clear why the second example doesn't work as intended - The Object class's equals method simply compares the references of the objects, i.e. it returns the value of this==otherObject.
May this issue apply to your case? Maybe you should override the equals-method in DragHandler to simply return true unconditionally.