Hi i've got a JPanel which contains a JButton. Now, i'm able to drag this JButton anywhere inside the panel fine. Normally, if i were to just click on this button, a new jframe would appear which contains a jtextarea.

My question is, that, everytime I click on the Jbutton to drag, when i drag it and then release it, the jbutton activates the actionperformed. So the jtextarea popup keeps appearing.

Any way to filter this so that the program recognises that when i drag, just drag, and when i click once, open the popup?

I don't know if it can be done but instead of using the ActionListener interface, you can use the MouseListener interface. Check the API of the JButton to see if it can accept such a listener. If yes, then look at the methods that it has.

Also when you drag the button you can set a variable to true and check that variable when you click the button to determine if it was dragged or not. When the button is released after it is dragged you can set that variable back to false.