0

In my application, I want to know what kind of cursor is displayed (default, move, resize, etc..).
For this I am using the getCursor method, which works fine in all cases except when I am performing a Drag and Drop using java swing DnD.

When I am performing a drag and drop, the Component.getCursor() method returns a Default Cursor instance, while the mouse is application is displaying a DnD cursor.

Is there any way to get the Cursor information when a Drag and drop is performed ?

Paul
  • 1
  • 1
  • 1
    This sounds like an xy problem. Why is the displayed cursor relevant? Isn’t [the actual action](https://docs.oracle.com/en/java/javase/15/docs/api/java.desktop/java/awt/dnd/DropTargetDragEvent.html#getDropAction()) relevant, regardless of how the current desktop displays it? – Holger Sep 22 '20 at 09:53
  • I'm not entirely sure how this behavior can be explained, but [this thread](https://stackoverflow.com/questions/13729078/java-drag-and-drop-custom-cursor) seems to explore a similar problem. – yur Sep 22 '20 at 10:40
  • @Holger, I don't think this is a xy problem, because the [getCursor](https://docs.oracle.com/javase/7/docs/api/java/awt/Component.html#getCursor()) method do not take any mouse position in argument. You are right, what is relevant for the code is the actual action, but I need the cursor for an automatic HMI test tool which gets the component information. It seems that the swing rendering is bypassing the Component cursor when a drag action is on-going, I would like to know if/how we can get this information – Paul Sep 23 '20 at 11:54
  • 1
    Your reasoning makes no sense. You don’t think, it’s an xy problem, because the method I suspected not to be the right thing is indeed not the right thing? And then, you even approve that it is an xy problem, because the actual problem is you want to make an automatic HMI test tool recognize the actual action (x) but ask about getting the cursor image (y). – Holger Sep 23 '20 at 12:14

0 Answers0