Detecting Drag and Drop event on Java FX? -


I have found some circle objects that I have a line when Drag from the circle.

I started with this code to test the drag and drop coordinate:

  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);}}};   

When I leave the mouse, when no circle is printed to console What is the correct perspective and how should I draw a line when dragging me.

To detect drag and drop, this Follow the approach:

  // // 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); *}});   

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.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -