Skip to content

OreDnDImageRender

Roman Obuhov edited this page Feb 2, 2022 · 3 revisions

OreDnDImageRender - Image rendering during the Drop and Drop process

OreDnDImageRender is NOT thread-safe, all its properties must be changed in the java.awt.EventQueue.dispatchThread thread.

The OreDnDImageRender.init method must be called before using OreDnDImageRender. In this method, a listener is added to java.awt.dnd.DragSource.getDefaultDragSource(), which allows to receive cursor movement events during the drag and drag end events. The OreDnDImageRender.init method is best run at the start of the application.

The image to be moved with the mouse cursor must be stored in the OreDnDImageRender.image property before the drag process begins. When the dragging process ends, the OreDnDImageRender.image property is set to null.

To adjust the location of the image relative to the cursor, you can change the property values:

  • imageOffsetX - indent image from the mouse cursor along the X axis, in pixels;
  • imageOffsetY - indent image from the mouse cursor along the Y axis, in pixels;
  • imageSideOrder - The order in which the image is positioned relative to the mouse cursor so that the image does not cross the edge of the screen

OreDnDImageRender uses a window to display the image, which is hidden when the drag process is complete. To have the dispose method called on this window when hidden, set the OreDnDImageRender.disposeDraggedWindowOnHide property to true.

Clone this wiki locally