java - How to drag a JavaFX node and detect a drop event outside the JavaFX Windows? -


I am implementing a tabkin that can be separated from the JavaFX window. When the tab panel is pulled out of the window where it came from, I have to create a new window and the tab to be placed in that window.

I have already applied some methods using drag gestures, drag the tab between the existing window. However, when I'm taking a mouse out of javax sequences, I'm not able to get any mouse events or drag events. Is this something possible?

You can listen to a mouse release incident on the appropriate node (like the graphic of the tab). Check the screen coordinates using MouseEvent.getScreenX () and MouseEvent.getScreenY () and see if they are out of the current window. If they do, create a new window, view and tab panel; Remove the tab from the current tab panel and place it in a new location.

There is no fundamental example with no frills (for example, a user does not indicate that the dragging is happening), but you should consider this:

  import Please javafx.application.Application; Import javafx.collections.ListChangeListener.Change; Import javafx.geometry.Point2D; Import javafx.geometry.Rectangle2D; Import javafx.scene.Scene; Import javafx.scene.control.button; Import javafx.scene.control.Label; Import javafx.scene.control.Tab; Import javafx.scene.control.TabPane; Import javafx.scene.control.TextArea; Import javafx.scene.layout.BorderPane; Import javafx.stage.Stage; Import javafx.stage.Window; Public class increases detachableTabExample application {Private Int tabCount = 0; @ Override Public Voic Rate (Stage Primary Stage) {TabPan TabPan = New TabPan (); Button newTabButton = new button ("new tab"); NewTabButton.setOnAction (Event -> Tab Tab = New Tab (); Label Tab Label = New Label ("Tab" + (++ TabCount); tab.setGraphic (Tabable); Tab. Set Content (New Textaria ); TabenGetTab () Add (Tab); Tabelabel. SetOnMessRelicated (me -> gt; {point2D mouseLoc = New point 2D (me.getScreenX), me.getScreenY ()); window window = tab page .getScene (). GetWindow (); Rectangle2D WindowBound = New Rectangle 2D (window.attacks), window.gette (), windowGetWidth (), windowGateHit ()); if (window-wide content (! MouseOk)) {tabPane.getTabs () .remove (tab); Stage Newestage = New Stage (); TabPen NewTapen = New TabEp (); NewType.GetTab () .Join (Tab); Visual View = New View (New BorderPan (Newteppan); n ewStage.setScene (view); newStage.setX (me.getScreenX ()); newStage.setY (me.getScreenY ()); newStage.setWidth (window.getWidth ()); newStage.setHeight ( Window.getHeight ()); newStage.show ();}}); }); BorderPan Root = New BorderPan (tabpain, newtubutan, empty, empty, empty); Visual view = new view (root, 600, 400); PrimaryStage.setScene (view); PrimaryStage.show (); } Public static zero main (string [] args) {launch (args); }}  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -