Skip to content

Drag and Drop not working on Linux when running via jPro LoadBalancer #204

@KniKnaKnorke

Description

@KniKnaKnorke

Hello,

I have the following sample code that implements a simple drag-and-drop feature. Items in the list can be moved to different positions.

public class Launcher extends JProApplication {

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

    @Override
    public void start(Stage stage) throws Exception {
        ObservableList<String> items = FXCollections.observableArrayList(
                "Item 1", "Item 2", "Item 3", "Item 4", "Item 5"
        );

        ListView<String> listView = new ListView<>(items);

        // Custom cells for drag & drop reorder
        listView.setCellFactory(lv -> {
            ListCell<String> cell = new ListCell<>() {
                @Override
                protected void updateItem(String item, boolean empty) {
                    super.updateItem(item, empty);
                    setText(empty ? null : item);
                }
            };

            // Start dragging
            cell.setOnDragDetected(e -> {
                System.err.println("setOnDragDetected");
                if (cell.isEmpty()) return;

                Dragboard db = cell.startDragAndDrop(TransferMode.MOVE);
                ClipboardContent content = new ClipboardContent();
                content.putString(cell.getItem()); // store item text
                db.setContent(content);

                // remember source index
                listView.getProperties().put("dragSourceIndex", cell.getIndex());
                e.consume();
            });

            // While dragging over a cell
            cell.setOnDragOver(e -> {
                System.err.println("setOnDragOver");
                if (cell.isEmpty()) return;

                Integer sourceIndex = (Integer) listView.getProperties().get("dragSourceIndex");
                if (sourceIndex == null) return;

                if (e.getGestureSource() != cell && e.getDragboard().hasString()) {
                    e.acceptTransferModes(TransferMode.MOVE);
                }
                e.consume();
            });

            // Drop onto a cell => reorder
            cell.setOnDragDropped(e -> {
                System.err.println("setOnDragDropped");
                Dragboard db = e.getDragboard();
                boolean success = false;

                Integer sourceIndex = (Integer) listView.getProperties().get("dragSourceIndex");
                if (sourceIndex != null && db.hasString() && !cell.isEmpty()) {
                    int targetIndex = cell.getIndex();

                    if (sourceIndex != targetIndex) {
                        String moved = items.remove((int) sourceIndex);

                        // if you remove an item above the target, the target index shifts by -1
                        if (sourceIndex < targetIndex) targetIndex--;

                        items.add(targetIndex, moved);
                        listView.getSelectionModel().select(targetIndex);
                    }
                    success = true;
                }

                e.setDropCompleted(success);
                e.consume();
            });

            // Cleanup
            cell.setOnDragDone(e -> {
                listView.getProperties().remove("dragSourceIndex");
                e.consume();
            });

            return cell;
        });

        stage.setTitle("JavaFX ListView Drag & Drop");
        stage.setScene(new Scene(listView, 300, 220));
        stage.show();
    }
}

When I run this code on Linux using Gradle or from the release package, drag and drop works perfectly.

However, when I run the application through the jPro LoadBalancer, drag and drop no longer works. It seems that the dragDetected event is still triggered, but no further drag-and-drop events occur.

I also noticed that on Windows, drag and drop works fine even when using the LoadBalancer.

System Information:
OS: Linux
jPro / LoadBalancer: 2026.1.0
Java / JavaFX: 21

Greetings,
Dennis Nolte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions