Drag and Drop working differently in Java 11 vs Java 8












8















I wrote a program which makes use of drag and drop in javafx. In JavaFX8 it works perfectly.



In JavaFX11, the drag and drop is dysfunctional: I don't get a different mouse cursor, I don't get a ghost image of the row I'm dragging, and something's wrong with the drops -- they don't trigger on mouse release, and then the drop is triggered each time I click on the table.



Here is minimum runnable example which demonstrates the issue I'm facing. Run on a Java 8 JVM it works as desired. On Java 11 JVM it does not. I am on Ubuntu 18.04.



I'm fine with changing my code to accommodate Java 11, but I don't have any idea what I'm doing wrong.



Java 11 Version



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


Java 8 Version



openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-1ubuntu0.18.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)


DND11.java



import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.stage.Stage;

public class DND11 extends Application {

public TableView<Person> getTable () {
DataFormat DRAGGED_PERSON = new DataFormat ( "application/example-person" );

TableColumn <Person, String> firstNameColumn = new TableColumn <> ( "First Name" );
TableColumn <Person, String> LastNameColumn = new TableColumn <> ( "Last Name" );

firstNameColumn.setCellValueFactory( new PropertyValueFactory <Person, String>( "firstName" ) );
LastNameColumn.setCellValueFactory( new PropertyValueFactory <Person, String>( "lastName" ) );

TableView <Person> tableView = new TableView <> ();
tableView.getColumns().addAll( firstNameColumn, LastNameColumn );
tableView.setColumnResizePolicy( TableView.CONSTRAINED_RESIZE_POLICY );

tableView.setEditable( false );
tableView.setItems( FXCollections.observableArrayList( Person.generatePersons ( 10 ) ) );

tableView.getSelectionModel().setSelectionMode( SelectionMode.MULTIPLE );

tableView.setRowFactory( tv -> {
TableRow <Person> row = new TableRow <>();

row.setOnDragDetected( event -> {
if ( !row.isEmpty() ) {
Dragboard db = row.startDragAndDrop( TransferMode.COPY );
ClipboardContent cc = new ClipboardContent();
cc.put( DRAGGED_PERSON, row.getItem() );
tableView.getItems().remove( row.getItem() );
db.setContent( cc );
}
});

row.setOnDragOver( event -> {
Dragboard db = event.getDragboard();
event.acceptTransferModes( TransferMode.COPY );
});

row.setOnDragDropped( event -> {
Dragboard db = event.getDragboard();

Person person = (Person)event.getDragboard().getContent( DRAGGED_PERSON );

if ( person != null ) {
tableView.getItems().remove( person );
int dropIndex = row.getIndex();
tableView.getItems().add( dropIndex, person );
}

event.setDropCompleted( true );
event.consume();
});

return row;
});

return tableView;
}

@Override
public void start ( Stage stage ) throws Exception {
stage.setScene( new Scene( getTable(), 800, 400 ) );
stage.show();

}

public static void main ( String args ) {
launch( args );
}
}


Person.java



import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Person implements Serializable {

private static final long serialVersionUID = 1L;

private String firstName, lastName;

public Person ( String firstName, String lastName ) {
this.firstName = firstName;
this.lastName = lastName;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public static List <Person> generatePersons ( int number ) {
List<Person> retMe = new ArrayList<Person> ( number );
for ( int k = 0; k < number; k++ ) {
retMe.add ( new Person ( randomFirstName(), randomLastName() ) );
}
return retMe;
}


private static Random rand = new Random();

private static String randomFirstName() {
return firstNames [ Math.abs( rand.nextInt() ) % firstNames.length ];
}

private static String randomLastName() {
return lastNames [ Math.abs( rand.nextInt() ) % lastNames.length ];
}

private static String firstNames = new String {
"ANTON","ANTONE","ANTONIA","NTONIO","ANTONY","ANTWAN","ARCHIE","ARDEN","ARIEL","ARLEN",
"ARMAND","ARMANDO","ARNOLD","ARNOLDO","ARNULF","ARON","ARRON","ART","ARTHUR","ARTURO",
"DARRICK","DARRIN","DARRON","DARRYL","DARWIN","DARYL","DAVE","DAVID","DAVIS","DEAN",

};

private static String lastNames = new String {
"SMITH","JOHNSON","WILLIAMS","BROWN","JONES","MILLER","DAVIS","GARCIA","RODRIGUEZ",
"WILSON","MARTINEZ","ANDERSON","TAYLOR","THOMAS","HERNANDEZ","MOORE","MARTIN","JACKSON"
};
}









share|improve this question




















  • 6





    DND is quite platform specific. I've run it on Windows and Mac and it works same on 8 and 11. I haven't checked on Linux, but there is an important change made on 11, related to the use of GTK 3. Can you try with GTK 2 (-Djdk.gtk.version=2)?

    – José Pereda
    Nov 16 '18 at 10:11











  • That did it. You're the man! If you want to make a full answer I will accept it.

    – JoshuaD
    Nov 17 '18 at 1:18






  • 3





    @JoséPereda It's worth making your comment an answer, with the relevant details around the change you've mentioned.

    – nullpointer
    Nov 17 '18 at 3:29
















8















I wrote a program which makes use of drag and drop in javafx. In JavaFX8 it works perfectly.



In JavaFX11, the drag and drop is dysfunctional: I don't get a different mouse cursor, I don't get a ghost image of the row I'm dragging, and something's wrong with the drops -- they don't trigger on mouse release, and then the drop is triggered each time I click on the table.



Here is minimum runnable example which demonstrates the issue I'm facing. Run on a Java 8 JVM it works as desired. On Java 11 JVM it does not. I am on Ubuntu 18.04.



I'm fine with changing my code to accommodate Java 11, but I don't have any idea what I'm doing wrong.



Java 11 Version



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


Java 8 Version



openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-1ubuntu0.18.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)


DND11.java



import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.stage.Stage;

public class DND11 extends Application {

public TableView<Person> getTable () {
DataFormat DRAGGED_PERSON = new DataFormat ( "application/example-person" );

TableColumn <Person, String> firstNameColumn = new TableColumn <> ( "First Name" );
TableColumn <Person, String> LastNameColumn = new TableColumn <> ( "Last Name" );

firstNameColumn.setCellValueFactory( new PropertyValueFactory <Person, String>( "firstName" ) );
LastNameColumn.setCellValueFactory( new PropertyValueFactory <Person, String>( "lastName" ) );

TableView <Person> tableView = new TableView <> ();
tableView.getColumns().addAll( firstNameColumn, LastNameColumn );
tableView.setColumnResizePolicy( TableView.CONSTRAINED_RESIZE_POLICY );

tableView.setEditable( false );
tableView.setItems( FXCollections.observableArrayList( Person.generatePersons ( 10 ) ) );

tableView.getSelectionModel().setSelectionMode( SelectionMode.MULTIPLE );

tableView.setRowFactory( tv -> {
TableRow <Person> row = new TableRow <>();

row.setOnDragDetected( event -> {
if ( !row.isEmpty() ) {
Dragboard db = row.startDragAndDrop( TransferMode.COPY );
ClipboardContent cc = new ClipboardContent();
cc.put( DRAGGED_PERSON, row.getItem() );
tableView.getItems().remove( row.getItem() );
db.setContent( cc );
}
});

row.setOnDragOver( event -> {
Dragboard db = event.getDragboard();
event.acceptTransferModes( TransferMode.COPY );
});

row.setOnDragDropped( event -> {
Dragboard db = event.getDragboard();

Person person = (Person)event.getDragboard().getContent( DRAGGED_PERSON );

if ( person != null ) {
tableView.getItems().remove( person );
int dropIndex = row.getIndex();
tableView.getItems().add( dropIndex, person );
}

event.setDropCompleted( true );
event.consume();
});

return row;
});

return tableView;
}

@Override
public void start ( Stage stage ) throws Exception {
stage.setScene( new Scene( getTable(), 800, 400 ) );
stage.show();

}

public static void main ( String args ) {
launch( args );
}
}


Person.java



import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Person implements Serializable {

private static final long serialVersionUID = 1L;

private String firstName, lastName;

public Person ( String firstName, String lastName ) {
this.firstName = firstName;
this.lastName = lastName;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public static List <Person> generatePersons ( int number ) {
List<Person> retMe = new ArrayList<Person> ( number );
for ( int k = 0; k < number; k++ ) {
retMe.add ( new Person ( randomFirstName(), randomLastName() ) );
}
return retMe;
}


private static Random rand = new Random();

private static String randomFirstName() {
return firstNames [ Math.abs( rand.nextInt() ) % firstNames.length ];
}

private static String randomLastName() {
return lastNames [ Math.abs( rand.nextInt() ) % lastNames.length ];
}

private static String firstNames = new String {
"ANTON","ANTONE","ANTONIA","NTONIO","ANTONY","ANTWAN","ARCHIE","ARDEN","ARIEL","ARLEN",
"ARMAND","ARMANDO","ARNOLD","ARNOLDO","ARNULF","ARON","ARRON","ART","ARTHUR","ARTURO",
"DARRICK","DARRIN","DARRON","DARRYL","DARWIN","DARYL","DAVE","DAVID","DAVIS","DEAN",

};

private static String lastNames = new String {
"SMITH","JOHNSON","WILLIAMS","BROWN","JONES","MILLER","DAVIS","GARCIA","RODRIGUEZ",
"WILSON","MARTINEZ","ANDERSON","TAYLOR","THOMAS","HERNANDEZ","MOORE","MARTIN","JACKSON"
};
}









share|improve this question




















  • 6





    DND is quite platform specific. I've run it on Windows and Mac and it works same on 8 and 11. I haven't checked on Linux, but there is an important change made on 11, related to the use of GTK 3. Can you try with GTK 2 (-Djdk.gtk.version=2)?

    – José Pereda
    Nov 16 '18 at 10:11











  • That did it. You're the man! If you want to make a full answer I will accept it.

    – JoshuaD
    Nov 17 '18 at 1:18






  • 3





    @JoséPereda It's worth making your comment an answer, with the relevant details around the change you've mentioned.

    – nullpointer
    Nov 17 '18 at 3:29














8












8








8


2






I wrote a program which makes use of drag and drop in javafx. In JavaFX8 it works perfectly.



In JavaFX11, the drag and drop is dysfunctional: I don't get a different mouse cursor, I don't get a ghost image of the row I'm dragging, and something's wrong with the drops -- they don't trigger on mouse release, and then the drop is triggered each time I click on the table.



Here is minimum runnable example which demonstrates the issue I'm facing. Run on a Java 8 JVM it works as desired. On Java 11 JVM it does not. I am on Ubuntu 18.04.



I'm fine with changing my code to accommodate Java 11, but I don't have any idea what I'm doing wrong.



Java 11 Version



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


Java 8 Version



openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-1ubuntu0.18.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)


DND11.java



import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.stage.Stage;

public class DND11 extends Application {

public TableView<Person> getTable () {
DataFormat DRAGGED_PERSON = new DataFormat ( "application/example-person" );

TableColumn <Person, String> firstNameColumn = new TableColumn <> ( "First Name" );
TableColumn <Person, String> LastNameColumn = new TableColumn <> ( "Last Name" );

firstNameColumn.setCellValueFactory( new PropertyValueFactory <Person, String>( "firstName" ) );
LastNameColumn.setCellValueFactory( new PropertyValueFactory <Person, String>( "lastName" ) );

TableView <Person> tableView = new TableView <> ();
tableView.getColumns().addAll( firstNameColumn, LastNameColumn );
tableView.setColumnResizePolicy( TableView.CONSTRAINED_RESIZE_POLICY );

tableView.setEditable( false );
tableView.setItems( FXCollections.observableArrayList( Person.generatePersons ( 10 ) ) );

tableView.getSelectionModel().setSelectionMode( SelectionMode.MULTIPLE );

tableView.setRowFactory( tv -> {
TableRow <Person> row = new TableRow <>();

row.setOnDragDetected( event -> {
if ( !row.isEmpty() ) {
Dragboard db = row.startDragAndDrop( TransferMode.COPY );
ClipboardContent cc = new ClipboardContent();
cc.put( DRAGGED_PERSON, row.getItem() );
tableView.getItems().remove( row.getItem() );
db.setContent( cc );
}
});

row.setOnDragOver( event -> {
Dragboard db = event.getDragboard();
event.acceptTransferModes( TransferMode.COPY );
});

row.setOnDragDropped( event -> {
Dragboard db = event.getDragboard();

Person person = (Person)event.getDragboard().getContent( DRAGGED_PERSON );

if ( person != null ) {
tableView.getItems().remove( person );
int dropIndex = row.getIndex();
tableView.getItems().add( dropIndex, person );
}

event.setDropCompleted( true );
event.consume();
});

return row;
});

return tableView;
}

@Override
public void start ( Stage stage ) throws Exception {
stage.setScene( new Scene( getTable(), 800, 400 ) );
stage.show();

}

public static void main ( String args ) {
launch( args );
}
}


Person.java



import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Person implements Serializable {

private static final long serialVersionUID = 1L;

private String firstName, lastName;

public Person ( String firstName, String lastName ) {
this.firstName = firstName;
this.lastName = lastName;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public static List <Person> generatePersons ( int number ) {
List<Person> retMe = new ArrayList<Person> ( number );
for ( int k = 0; k < number; k++ ) {
retMe.add ( new Person ( randomFirstName(), randomLastName() ) );
}
return retMe;
}


private static Random rand = new Random();

private static String randomFirstName() {
return firstNames [ Math.abs( rand.nextInt() ) % firstNames.length ];
}

private static String randomLastName() {
return lastNames [ Math.abs( rand.nextInt() ) % lastNames.length ];
}

private static String firstNames = new String {
"ANTON","ANTONE","ANTONIA","NTONIO","ANTONY","ANTWAN","ARCHIE","ARDEN","ARIEL","ARLEN",
"ARMAND","ARMANDO","ARNOLD","ARNOLDO","ARNULF","ARON","ARRON","ART","ARTHUR","ARTURO",
"DARRICK","DARRIN","DARRON","DARRYL","DARWIN","DARYL","DAVE","DAVID","DAVIS","DEAN",

};

private static String lastNames = new String {
"SMITH","JOHNSON","WILLIAMS","BROWN","JONES","MILLER","DAVIS","GARCIA","RODRIGUEZ",
"WILSON","MARTINEZ","ANDERSON","TAYLOR","THOMAS","HERNANDEZ","MOORE","MARTIN","JACKSON"
};
}









share|improve this question
















I wrote a program which makes use of drag and drop in javafx. In JavaFX8 it works perfectly.



In JavaFX11, the drag and drop is dysfunctional: I don't get a different mouse cursor, I don't get a ghost image of the row I'm dragging, and something's wrong with the drops -- they don't trigger on mouse release, and then the drop is triggered each time I click on the table.



Here is minimum runnable example which demonstrates the issue I'm facing. Run on a Java 8 JVM it works as desired. On Java 11 JVM it does not. I am on Ubuntu 18.04.



I'm fine with changing my code to accommodate Java 11, but I don't have any idea what I'm doing wrong.



Java 11 Version



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


Java 8 Version



openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-1ubuntu0.18.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)


DND11.java



import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.stage.Stage;

public class DND11 extends Application {

public TableView<Person> getTable () {
DataFormat DRAGGED_PERSON = new DataFormat ( "application/example-person" );

TableColumn <Person, String> firstNameColumn = new TableColumn <> ( "First Name" );
TableColumn <Person, String> LastNameColumn = new TableColumn <> ( "Last Name" );

firstNameColumn.setCellValueFactory( new PropertyValueFactory <Person, String>( "firstName" ) );
LastNameColumn.setCellValueFactory( new PropertyValueFactory <Person, String>( "lastName" ) );

TableView <Person> tableView = new TableView <> ();
tableView.getColumns().addAll( firstNameColumn, LastNameColumn );
tableView.setColumnResizePolicy( TableView.CONSTRAINED_RESIZE_POLICY );

tableView.setEditable( false );
tableView.setItems( FXCollections.observableArrayList( Person.generatePersons ( 10 ) ) );

tableView.getSelectionModel().setSelectionMode( SelectionMode.MULTIPLE );

tableView.setRowFactory( tv -> {
TableRow <Person> row = new TableRow <>();

row.setOnDragDetected( event -> {
if ( !row.isEmpty() ) {
Dragboard db = row.startDragAndDrop( TransferMode.COPY );
ClipboardContent cc = new ClipboardContent();
cc.put( DRAGGED_PERSON, row.getItem() );
tableView.getItems().remove( row.getItem() );
db.setContent( cc );
}
});

row.setOnDragOver( event -> {
Dragboard db = event.getDragboard();
event.acceptTransferModes( TransferMode.COPY );
});

row.setOnDragDropped( event -> {
Dragboard db = event.getDragboard();

Person person = (Person)event.getDragboard().getContent( DRAGGED_PERSON );

if ( person != null ) {
tableView.getItems().remove( person );
int dropIndex = row.getIndex();
tableView.getItems().add( dropIndex, person );
}

event.setDropCompleted( true );
event.consume();
});

return row;
});

return tableView;
}

@Override
public void start ( Stage stage ) throws Exception {
stage.setScene( new Scene( getTable(), 800, 400 ) );
stage.show();

}

public static void main ( String args ) {
launch( args );
}
}


Person.java



import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Person implements Serializable {

private static final long serialVersionUID = 1L;

private String firstName, lastName;

public Person ( String firstName, String lastName ) {
this.firstName = firstName;
this.lastName = lastName;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public static List <Person> generatePersons ( int number ) {
List<Person> retMe = new ArrayList<Person> ( number );
for ( int k = 0; k < number; k++ ) {
retMe.add ( new Person ( randomFirstName(), randomLastName() ) );
}
return retMe;
}


private static Random rand = new Random();

private static String randomFirstName() {
return firstNames [ Math.abs( rand.nextInt() ) % firstNames.length ];
}

private static String randomLastName() {
return lastNames [ Math.abs( rand.nextInt() ) % lastNames.length ];
}

private static String firstNames = new String {
"ANTON","ANTONE","ANTONIA","NTONIO","ANTONY","ANTWAN","ARCHIE","ARDEN","ARIEL","ARLEN",
"ARMAND","ARMANDO","ARNOLD","ARNOLDO","ARNULF","ARON","ARRON","ART","ARTHUR","ARTURO",
"DARRICK","DARRIN","DARRON","DARRYL","DARWIN","DARYL","DAVE","DAVID","DAVIS","DEAN",

};

private static String lastNames = new String {
"SMITH","JOHNSON","WILLIAMS","BROWN","JONES","MILLER","DAVIS","GARCIA","RODRIGUEZ",
"WILSON","MARTINEZ","ANDERSON","TAYLOR","THOMAS","HERNANDEZ","MOORE","MARTIN","JACKSON"
};
}






javafx java-8 migration javafx-8 java-11






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 19:21







JoshuaD

















asked Nov 16 '18 at 7:36









JoshuaDJoshuaD

1,20031735




1,20031735








  • 6





    DND is quite platform specific. I've run it on Windows and Mac and it works same on 8 and 11. I haven't checked on Linux, but there is an important change made on 11, related to the use of GTK 3. Can you try with GTK 2 (-Djdk.gtk.version=2)?

    – José Pereda
    Nov 16 '18 at 10:11











  • That did it. You're the man! If you want to make a full answer I will accept it.

    – JoshuaD
    Nov 17 '18 at 1:18






  • 3





    @JoséPereda It's worth making your comment an answer, with the relevant details around the change you've mentioned.

    – nullpointer
    Nov 17 '18 at 3:29














  • 6





    DND is quite platform specific. I've run it on Windows and Mac and it works same on 8 and 11. I haven't checked on Linux, but there is an important change made on 11, related to the use of GTK 3. Can you try with GTK 2 (-Djdk.gtk.version=2)?

    – José Pereda
    Nov 16 '18 at 10:11











  • That did it. You're the man! If you want to make a full answer I will accept it.

    – JoshuaD
    Nov 17 '18 at 1:18






  • 3





    @JoséPereda It's worth making your comment an answer, with the relevant details around the change you've mentioned.

    – nullpointer
    Nov 17 '18 at 3:29








6




6





DND is quite platform specific. I've run it on Windows and Mac and it works same on 8 and 11. I haven't checked on Linux, but there is an important change made on 11, related to the use of GTK 3. Can you try with GTK 2 (-Djdk.gtk.version=2)?

– José Pereda
Nov 16 '18 at 10:11





DND is quite platform specific. I've run it on Windows and Mac and it works same on 8 and 11. I haven't checked on Linux, but there is an important change made on 11, related to the use of GTK 3. Can you try with GTK 2 (-Djdk.gtk.version=2)?

– José Pereda
Nov 16 '18 at 10:11













That did it. You're the man! If you want to make a full answer I will accept it.

– JoshuaD
Nov 17 '18 at 1:18





That did it. You're the man! If you want to make a full answer I will accept it.

– JoshuaD
Nov 17 '18 at 1:18




3




3





@JoséPereda It's worth making your comment an answer, with the relevant details around the change you've mentioned.

– nullpointer
Nov 17 '18 at 3:29





@JoséPereda It's worth making your comment an answer, with the relevant details around the change you've mentioned.

– nullpointer
Nov 17 '18 at 3:29












1 Answer
1






active

oldest

votes


















6














While Drag and Drop in JavaFX has a common API for all the platforms (as the rest of the API, of course), its internal implementation is platform dependent, and it is quite different on Windows, Mac or Linux.



But this shouldn't be an issue when migrating from JavaFX 8 to JavaFX 11, though.



The sample posted by the OP works the same on Windows and Mac with both JavaFX 8 and 11, and if it is not the case on Linux, it might have to do with the changes done in the latest release of JavaFX for Linux.



According to the releases note, under the Important Changes section we can see:




Switch default GTK version to 3



JavaFX will now use GTK 3 by default on Linux platforms where the gtk3 library is present. Prior to JavaFX 11, the GTK 2 library was the default. This matches the default for AWT in JDK 11. See JDK-8198654 for more information.




While this change was basically a two lines diff in the JavaFX code, and nothing changed from the implementation details for DND, the GTK 3 implementation might have changed from GTK 2, and those changes haven't been taken into account.



Similar issues related to GTK have been reported for dialogs, windows or Wayland crashes.



Workaround



So far the only known workaround for all of those issues is to run the app with GTK 2, that can be set with the system property: jdk.gtk.version.



So this option can be added on command line:



java -Djdk.gtk.version=2 ...


to run the application.



As posted in the comments, this seems to solve the drag and drop issue.



Report the issue



Definitely, that confirms that this is an issue, and as such it should be filed at the OpenJFX issue tracker, providing the sample code to reproduce it, system details (OS version, Java version, JavaFX version...).






share|improve this answer























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


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333364%2fdrag-and-drop-working-differently-in-java-11-vs-java-8%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









    6














    While Drag and Drop in JavaFX has a common API for all the platforms (as the rest of the API, of course), its internal implementation is platform dependent, and it is quite different on Windows, Mac or Linux.



    But this shouldn't be an issue when migrating from JavaFX 8 to JavaFX 11, though.



    The sample posted by the OP works the same on Windows and Mac with both JavaFX 8 and 11, and if it is not the case on Linux, it might have to do with the changes done in the latest release of JavaFX for Linux.



    According to the releases note, under the Important Changes section we can see:




    Switch default GTK version to 3



    JavaFX will now use GTK 3 by default on Linux platforms where the gtk3 library is present. Prior to JavaFX 11, the GTK 2 library was the default. This matches the default for AWT in JDK 11. See JDK-8198654 for more information.




    While this change was basically a two lines diff in the JavaFX code, and nothing changed from the implementation details for DND, the GTK 3 implementation might have changed from GTK 2, and those changes haven't been taken into account.



    Similar issues related to GTK have been reported for dialogs, windows or Wayland crashes.



    Workaround



    So far the only known workaround for all of those issues is to run the app with GTK 2, that can be set with the system property: jdk.gtk.version.



    So this option can be added on command line:



    java -Djdk.gtk.version=2 ...


    to run the application.



    As posted in the comments, this seems to solve the drag and drop issue.



    Report the issue



    Definitely, that confirms that this is an issue, and as such it should be filed at the OpenJFX issue tracker, providing the sample code to reproduce it, system details (OS version, Java version, JavaFX version...).






    share|improve this answer




























      6














      While Drag and Drop in JavaFX has a common API for all the platforms (as the rest of the API, of course), its internal implementation is platform dependent, and it is quite different on Windows, Mac or Linux.



      But this shouldn't be an issue when migrating from JavaFX 8 to JavaFX 11, though.



      The sample posted by the OP works the same on Windows and Mac with both JavaFX 8 and 11, and if it is not the case on Linux, it might have to do with the changes done in the latest release of JavaFX for Linux.



      According to the releases note, under the Important Changes section we can see:




      Switch default GTK version to 3



      JavaFX will now use GTK 3 by default on Linux platforms where the gtk3 library is present. Prior to JavaFX 11, the GTK 2 library was the default. This matches the default for AWT in JDK 11. See JDK-8198654 for more information.




      While this change was basically a two lines diff in the JavaFX code, and nothing changed from the implementation details for DND, the GTK 3 implementation might have changed from GTK 2, and those changes haven't been taken into account.



      Similar issues related to GTK have been reported for dialogs, windows or Wayland crashes.



      Workaround



      So far the only known workaround for all of those issues is to run the app with GTK 2, that can be set with the system property: jdk.gtk.version.



      So this option can be added on command line:



      java -Djdk.gtk.version=2 ...


      to run the application.



      As posted in the comments, this seems to solve the drag and drop issue.



      Report the issue



      Definitely, that confirms that this is an issue, and as such it should be filed at the OpenJFX issue tracker, providing the sample code to reproduce it, system details (OS version, Java version, JavaFX version...).






      share|improve this answer


























        6












        6








        6







        While Drag and Drop in JavaFX has a common API for all the platforms (as the rest of the API, of course), its internal implementation is platform dependent, and it is quite different on Windows, Mac or Linux.



        But this shouldn't be an issue when migrating from JavaFX 8 to JavaFX 11, though.



        The sample posted by the OP works the same on Windows and Mac with both JavaFX 8 and 11, and if it is not the case on Linux, it might have to do with the changes done in the latest release of JavaFX for Linux.



        According to the releases note, under the Important Changes section we can see:




        Switch default GTK version to 3



        JavaFX will now use GTK 3 by default on Linux platforms where the gtk3 library is present. Prior to JavaFX 11, the GTK 2 library was the default. This matches the default for AWT in JDK 11. See JDK-8198654 for more information.




        While this change was basically a two lines diff in the JavaFX code, and nothing changed from the implementation details for DND, the GTK 3 implementation might have changed from GTK 2, and those changes haven't been taken into account.



        Similar issues related to GTK have been reported for dialogs, windows or Wayland crashes.



        Workaround



        So far the only known workaround for all of those issues is to run the app with GTK 2, that can be set with the system property: jdk.gtk.version.



        So this option can be added on command line:



        java -Djdk.gtk.version=2 ...


        to run the application.



        As posted in the comments, this seems to solve the drag and drop issue.



        Report the issue



        Definitely, that confirms that this is an issue, and as such it should be filed at the OpenJFX issue tracker, providing the sample code to reproduce it, system details (OS version, Java version, JavaFX version...).






        share|improve this answer













        While Drag and Drop in JavaFX has a common API for all the platforms (as the rest of the API, of course), its internal implementation is platform dependent, and it is quite different on Windows, Mac or Linux.



        But this shouldn't be an issue when migrating from JavaFX 8 to JavaFX 11, though.



        The sample posted by the OP works the same on Windows and Mac with both JavaFX 8 and 11, and if it is not the case on Linux, it might have to do with the changes done in the latest release of JavaFX for Linux.



        According to the releases note, under the Important Changes section we can see:




        Switch default GTK version to 3



        JavaFX will now use GTK 3 by default on Linux platforms where the gtk3 library is present. Prior to JavaFX 11, the GTK 2 library was the default. This matches the default for AWT in JDK 11. See JDK-8198654 for more information.




        While this change was basically a two lines diff in the JavaFX code, and nothing changed from the implementation details for DND, the GTK 3 implementation might have changed from GTK 2, and those changes haven't been taken into account.



        Similar issues related to GTK have been reported for dialogs, windows or Wayland crashes.



        Workaround



        So far the only known workaround for all of those issues is to run the app with GTK 2, that can be set with the system property: jdk.gtk.version.



        So this option can be added on command line:



        java -Djdk.gtk.version=2 ...


        to run the application.



        As posted in the comments, this seems to solve the drag and drop issue.



        Report the issue



        Definitely, that confirms that this is an issue, and as such it should be filed at the OpenJFX issue tracker, providing the sample code to reproduce it, system details (OS version, Java version, JavaFX version...).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 '18 at 12:52









        José PeredaJosé Pereda

        25.8k34269




        25.8k34269






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333364%2fdrag-and-drop-working-differently-in-java-11-vs-java-8%23new-answer', 'question_page');
            }
            );

            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







            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini