JavaFX: Alert popup after drag-and-drop action casues frozen drop icon
Using JavaFX 8 I'm experiencing a specific drag-and-drop problem:
The confirmation popup after dropping gets the icon stuck on screen when a drag is released, even overlaying the Alert dialog itself like so:
The text "copy" and the icon remain stuck until user closes the popup.
This is the minimal code to reproduce the problem. To test, run this program and drag any file (ex. from Desktop) into the app window:
public class Main extends Application {
private Parent root = new VBox();
private void onDragOver(DragEvent dragEvent) {
if (dragEvent.getDragboard().hasFiles()) {
dragEvent.acceptTransferModes(TransferMode.COPY);
}
}
private void isUserSure() {
Alert alert = new Alert(Alert.AlertType.WARNING,"",ButtonType.OK);
alert.showAndWait();
}
@Override
public void start(Stage primaryStage) {
root.setOnDragOver((event) -> onDragOver(event));
root.setOnDragDropped((event) -> isUserSure());
primaryStage.setTitle("ghost demo");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String args) {
launch(args);
}
}
java javafx popup alert frozen
add a comment |
Using JavaFX 8 I'm experiencing a specific drag-and-drop problem:
The confirmation popup after dropping gets the icon stuck on screen when a drag is released, even overlaying the Alert dialog itself like so:
The text "copy" and the icon remain stuck until user closes the popup.
This is the minimal code to reproduce the problem. To test, run this program and drag any file (ex. from Desktop) into the app window:
public class Main extends Application {
private Parent root = new VBox();
private void onDragOver(DragEvent dragEvent) {
if (dragEvent.getDragboard().hasFiles()) {
dragEvent.acceptTransferModes(TransferMode.COPY);
}
}
private void isUserSure() {
Alert alert = new Alert(Alert.AlertType.WARNING,"",ButtonType.OK);
alert.showAndWait();
}
@Override
public void start(Stage primaryStage) {
root.setOnDragOver((event) -> onDragOver(event));
root.setOnDragDropped((event) -> isUserSure());
primaryStage.setTitle("ghost demo");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String args) {
launch(args);
}
}
java javafx popup alert frozen
I do not guarantee this will work but try to empty the DragView: docs.oracle.com/javase/8/javafx/api/javafx/scene/input/… I searchedjavafx clear ghost drag
on Google
– Dom
Nov 19 '18 at 19:54
@Dom No joy, I tried, but thanks anyway. The doc says this "This method should be called only when starting drag and drop operation in the DRAG_DETECTED handler, calling it at other times doesn't have any effect."
– Pisces
Nov 19 '18 at 20:23
Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
– kleopatra
Nov 20 '18 at 9:20
Thanks for the advice @kleopatra, I've cleaned my question to the best of my ability.
– Pisces
Nov 20 '18 at 12:12
hmm ... can't reproduce: worksforme in fx8 and fx11 on win10
– kleopatra
Nov 20 '18 at 14:35
add a comment |
Using JavaFX 8 I'm experiencing a specific drag-and-drop problem:
The confirmation popup after dropping gets the icon stuck on screen when a drag is released, even overlaying the Alert dialog itself like so:
The text "copy" and the icon remain stuck until user closes the popup.
This is the minimal code to reproduce the problem. To test, run this program and drag any file (ex. from Desktop) into the app window:
public class Main extends Application {
private Parent root = new VBox();
private void onDragOver(DragEvent dragEvent) {
if (dragEvent.getDragboard().hasFiles()) {
dragEvent.acceptTransferModes(TransferMode.COPY);
}
}
private void isUserSure() {
Alert alert = new Alert(Alert.AlertType.WARNING,"",ButtonType.OK);
alert.showAndWait();
}
@Override
public void start(Stage primaryStage) {
root.setOnDragOver((event) -> onDragOver(event));
root.setOnDragDropped((event) -> isUserSure());
primaryStage.setTitle("ghost demo");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String args) {
launch(args);
}
}
java javafx popup alert frozen
Using JavaFX 8 I'm experiencing a specific drag-and-drop problem:
The confirmation popup after dropping gets the icon stuck on screen when a drag is released, even overlaying the Alert dialog itself like so:
The text "copy" and the icon remain stuck until user closes the popup.
This is the minimal code to reproduce the problem. To test, run this program and drag any file (ex. from Desktop) into the app window:
public class Main extends Application {
private Parent root = new VBox();
private void onDragOver(DragEvent dragEvent) {
if (dragEvent.getDragboard().hasFiles()) {
dragEvent.acceptTransferModes(TransferMode.COPY);
}
}
private void isUserSure() {
Alert alert = new Alert(Alert.AlertType.WARNING,"",ButtonType.OK);
alert.showAndWait();
}
@Override
public void start(Stage primaryStage) {
root.setOnDragOver((event) -> onDragOver(event));
root.setOnDragDropped((event) -> isUserSure());
primaryStage.setTitle("ghost demo");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String args) {
launch(args);
}
}
java javafx popup alert frozen
java javafx popup alert frozen
edited Nov 20 '18 at 12:08
Pisces
asked Nov 19 '18 at 19:45
PiscesPisces
62
62
I do not guarantee this will work but try to empty the DragView: docs.oracle.com/javase/8/javafx/api/javafx/scene/input/… I searchedjavafx clear ghost drag
on Google
– Dom
Nov 19 '18 at 19:54
@Dom No joy, I tried, but thanks anyway. The doc says this "This method should be called only when starting drag and drop operation in the DRAG_DETECTED handler, calling it at other times doesn't have any effect."
– Pisces
Nov 19 '18 at 20:23
Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
– kleopatra
Nov 20 '18 at 9:20
Thanks for the advice @kleopatra, I've cleaned my question to the best of my ability.
– Pisces
Nov 20 '18 at 12:12
hmm ... can't reproduce: worksforme in fx8 and fx11 on win10
– kleopatra
Nov 20 '18 at 14:35
add a comment |
I do not guarantee this will work but try to empty the DragView: docs.oracle.com/javase/8/javafx/api/javafx/scene/input/… I searchedjavafx clear ghost drag
on Google
– Dom
Nov 19 '18 at 19:54
@Dom No joy, I tried, but thanks anyway. The doc says this "This method should be called only when starting drag and drop operation in the DRAG_DETECTED handler, calling it at other times doesn't have any effect."
– Pisces
Nov 19 '18 at 20:23
Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
– kleopatra
Nov 20 '18 at 9:20
Thanks for the advice @kleopatra, I've cleaned my question to the best of my ability.
– Pisces
Nov 20 '18 at 12:12
hmm ... can't reproduce: worksforme in fx8 and fx11 on win10
– kleopatra
Nov 20 '18 at 14:35
I do not guarantee this will work but try to empty the DragView: docs.oracle.com/javase/8/javafx/api/javafx/scene/input/… I searched
javafx clear ghost drag
on Google– Dom
Nov 19 '18 at 19:54
I do not guarantee this will work but try to empty the DragView: docs.oracle.com/javase/8/javafx/api/javafx/scene/input/… I searched
javafx clear ghost drag
on Google– Dom
Nov 19 '18 at 19:54
@Dom No joy, I tried, but thanks anyway. The doc says this "This method should be called only when starting drag and drop operation in the DRAG_DETECTED handler, calling it at other times doesn't have any effect."
– Pisces
Nov 19 '18 at 20:23
@Dom No joy, I tried, but thanks anyway. The doc says this "This method should be called only when starting drag and drop operation in the DRAG_DETECTED handler, calling it at other times doesn't have any effect."
– Pisces
Nov 19 '18 at 20:23
Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
– kleopatra
Nov 20 '18 at 9:20
Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
– kleopatra
Nov 20 '18 at 9:20
Thanks for the advice @kleopatra, I've cleaned my question to the best of my ability.
– Pisces
Nov 20 '18 at 12:12
Thanks for the advice @kleopatra, I've cleaned my question to the best of my ability.
– Pisces
Nov 20 '18 at 12:12
hmm ... can't reproduce: worksforme in fx8 and fx11 on win10
– kleopatra
Nov 20 '18 at 14:35
hmm ... can't reproduce: worksforme in fx8 and fx11 on win10
– kleopatra
Nov 20 '18 at 14:35
add a comment |
1 Answer
1
active
oldest
votes
I solved it myself by doing the following:
Knowing that Modal Dialogs (Warning popups etc.) essentially "block" every other Stage via a call to showAndwait()
the problem must be that this also blocks the dragEvent
from finishing in the onDragDropped method (set via lambda in setOnDragDropped
).
Make sure you wrap the call to your popup method and the stuff that is to happen to the actual dropped items in a Platform.runLater()
This will let the dragEvent
stuff finish first. Observe the change I made in the following line of method start
:
root.setOnDragDropped((event) -> Platform.runLater(() -> isUserSure()));
Make sure you don't wrap more than you have to, otherwise the items in the Dragboard
will go out of scope. Extraction of needed items from Dragboard
has to happen at the time of drop, and not inside runLater()
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53381625%2fjavafx-alert-popup-after-drag-and-drop-action-casues-frozen-drop-icon%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I solved it myself by doing the following:
Knowing that Modal Dialogs (Warning popups etc.) essentially "block" every other Stage via a call to showAndwait()
the problem must be that this also blocks the dragEvent
from finishing in the onDragDropped method (set via lambda in setOnDragDropped
).
Make sure you wrap the call to your popup method and the stuff that is to happen to the actual dropped items in a Platform.runLater()
This will let the dragEvent
stuff finish first. Observe the change I made in the following line of method start
:
root.setOnDragDropped((event) -> Platform.runLater(() -> isUserSure()));
Make sure you don't wrap more than you have to, otherwise the items in the Dragboard
will go out of scope. Extraction of needed items from Dragboard
has to happen at the time of drop, and not inside runLater()
add a comment |
I solved it myself by doing the following:
Knowing that Modal Dialogs (Warning popups etc.) essentially "block" every other Stage via a call to showAndwait()
the problem must be that this also blocks the dragEvent
from finishing in the onDragDropped method (set via lambda in setOnDragDropped
).
Make sure you wrap the call to your popup method and the stuff that is to happen to the actual dropped items in a Platform.runLater()
This will let the dragEvent
stuff finish first. Observe the change I made in the following line of method start
:
root.setOnDragDropped((event) -> Platform.runLater(() -> isUserSure()));
Make sure you don't wrap more than you have to, otherwise the items in the Dragboard
will go out of scope. Extraction of needed items from Dragboard
has to happen at the time of drop, and not inside runLater()
add a comment |
I solved it myself by doing the following:
Knowing that Modal Dialogs (Warning popups etc.) essentially "block" every other Stage via a call to showAndwait()
the problem must be that this also blocks the dragEvent
from finishing in the onDragDropped method (set via lambda in setOnDragDropped
).
Make sure you wrap the call to your popup method and the stuff that is to happen to the actual dropped items in a Platform.runLater()
This will let the dragEvent
stuff finish first. Observe the change I made in the following line of method start
:
root.setOnDragDropped((event) -> Platform.runLater(() -> isUserSure()));
Make sure you don't wrap more than you have to, otherwise the items in the Dragboard
will go out of scope. Extraction of needed items from Dragboard
has to happen at the time of drop, and not inside runLater()
I solved it myself by doing the following:
Knowing that Modal Dialogs (Warning popups etc.) essentially "block" every other Stage via a call to showAndwait()
the problem must be that this also blocks the dragEvent
from finishing in the onDragDropped method (set via lambda in setOnDragDropped
).
Make sure you wrap the call to your popup method and the stuff that is to happen to the actual dropped items in a Platform.runLater()
This will let the dragEvent
stuff finish first. Observe the change I made in the following line of method start
:
root.setOnDragDropped((event) -> Platform.runLater(() -> isUserSure()));
Make sure you don't wrap more than you have to, otherwise the items in the Dragboard
will go out of scope. Extraction of needed items from Dragboard
has to happen at the time of drop, and not inside runLater()
edited Nov 21 '18 at 10:25
answered Nov 21 '18 at 10:17
PiscesPisces
62
62
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53381625%2fjavafx-alert-popup-after-drag-and-drop-action-casues-frozen-drop-icon%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I do not guarantee this will work but try to empty the DragView: docs.oracle.com/javase/8/javafx/api/javafx/scene/input/… I searched
javafx clear ghost drag
on Google– Dom
Nov 19 '18 at 19:54
@Dom No joy, I tried, but thanks anyway. The doc says this "This method should be called only when starting drag and drop operation in the DRAG_DETECTED handler, calling it at other times doesn't have any effect."
– Pisces
Nov 19 '18 at 20:23
Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
– kleopatra
Nov 20 '18 at 9:20
Thanks for the advice @kleopatra, I've cleaned my question to the best of my ability.
– Pisces
Nov 20 '18 at 12:12
hmm ... can't reproduce: worksforme in fx8 and fx11 on win10
– kleopatra
Nov 20 '18 at 14:35