Detecting Drag and Drop event on Java FX? -
I have found some I started with this code to test the drag and drop coordinate: When I leave the mouse, when no To detect drag and drop, this Follow the approach: Change the commented part to whatever you need. In your case, save the initial event coordinates (X, Y) and in the "dragged" section, use them as the initial coordinates for your line. circle objects that I have a
line when Drag from the circle.
circle node = new circle (15.0); Nodo.setOnDragDetected (new event handler & lt; mouse Event & gt; () {@ Override Public Wide Handle (Mouse Event Event) {Coordination [0] = Event .getX (); Coordination [1] = event.getY ();}} ); Nodo.setOnDragDropped (New EventHandler & lt; DragEvent & gt; () {@Override Public Invalid Handle (Dragravent Event) {Sync [2] = event.getX (); Coordination [3] = event.getY (); System out.println (coordination);}}};
circle is printed to console What is the correct perspective and how should I draw a
line when dragging me.
// // Mouse preceded // -------------------- - nodo.numuspressproperty () Set (New Event Handler & lt; Mouse Event & gt; () {@ Override Public Wide Handle (Mouse Event Event) {event.setDragDetect (true); node .setfex (New DropShadow (10.0, Color. Black))}}) Mouse dragged on // // ---------------------- node.onmouse drawingsproperty (). Set (new event handler & lt; mouse event & gt; () {@ Override Public Zero Handle (Mouse Event Eve Print) {Nodosetsetfaccr (new Dropshaido (10.0, color. BlueViolity) / * Last Circle Indicator = New Circle (3); Indicator .setstroke (color. Bluevolt); Indicator.SetCenterX (X); Indicator.setCenterY (y); *}});
Comments
Post a Comment