Package javafx.scene.input

Examples of javafx.scene.input.Dragboard


        Pane root = new WebViewPane();
        Scene scene = new Scene(root, 1280, 900);
           scene.setOnDragOver(new EventHandler<DragEvent>() {
                 @Override
                 public void handle(DragEvent event) {
                     Dragboard db = event.getDragboard();
                     if (db.hasFiles()) {
                         event.acceptTransferModes(TransferMode.COPY);
                     } else {
                         event.consume();
                     }
                 }
             });
          
                        // Dropping over surface
            scene.setOnDragDropped(new EventHandler<DragEvent>() {
                @Override
                public void handle(DragEvent event) {
                    Dragboard db = event.getDragboard();
                    boolean success = false;
                    if (db.hasFiles()) {
                        success = true;
                        String filePath;
                        for (File file:db.getFiles()) {
                            filePath = file.getAbsolutePath();
                            locationField.setText(filePath);
                        }
                    }
                    event.setDropCompleted(success);
View Full Code Here


            log.error("Could not load image", image.getException());
        }
    }

    public void imageSelectorDragOver(DragEvent event) {
        Dragboard dragboard = event.getDragboard();
        if (dragboard.getFiles().size() == 1) {
            final String name = dragboard.getFiles().get(0).toString().toLowerCase();
            if (name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".png")) {
                event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
                return;
            }
        }
        if (dragboard.getUrl() != null) {
            // We accept all URLs and filter out the non-image ones later.
            event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
        }
    }
View Full Code Here

  public void cellCreated(final Cell<?> treeCell) {

    treeCell.setOnDragDetected(new EventHandler<MouseEvent>() {
      public void handle(MouseEvent event) {
        /* allow any transfer mode */
        Dragboard db = treeCell.startDragAndDrop(TransferMode.ANY);

        /* put a string on dummy content dragboard */
        ClipboardContent content = new ClipboardContent();
        content.putString("dummy content");
        db.setContent(content);

        MultipleSelectionModel<?> selectionModel = getSelectionModel(treeCell);
        ObservableList<?> selectedItems = selectionModel.getSelectedItems();

        List<Object> items = new ArrayList<>(selectedItems.size());
View Full Code Here

TOP

Related Classes of javafx.scene.input.Dragboard

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.