当前位置: 首页>>代码示例>>Java>>正文


Java Dragboard类代码示例

本文整理汇总了Java中javafx.scene.input.Dragboard的典型用法代码示例。如果您正苦于以下问题:Java Dragboard类的具体用法?Java Dragboard怎么用?Java Dragboard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Dragboard类属于javafx.scene.input包,在下文中一共展示了Dragboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setOnDragDetected

import javafx.scene.input.Dragboard; //导入依赖的package包/类
/**
 * When the dragging is detected, we place the content of the LabelCell
 * in the DragBoard.
 */
void setOnDragDetected() {
    setOnDragDetected(event -> {

        boolean isParentTask = getTreeItem().getParent().equals(root);

        boolean isEmpty = getTreeItem().getValue().getText().equals("");

        if (!isEmpty && isParentTask) {
            Dragboard db = startDragAndDrop(TransferMode.MOVE);
            ClipboardContent content = new ClipboardContent();
            content.put(controller.DATA_FORMAT, getTreeItem()
                    .getValue());
            db.setContent(content);
        }
        event.consume();
    });
}
 
开发者ID:deltadak,项目名称:plep,代码行数:22,代码来源:CustomTreeCell.java

示例2: mouseDragDropped

import javafx.scene.input.Dragboard; //导入依赖的package包/类
/**
 * Handle mouse drop events
 * 
 * @param e
 */
private void mouseDragDropped(final DragEvent e) {
	final Dragboard db = e.getDragboard();
	boolean success = false;

	if (db.hasFiles()) {
		success = true;
		boolean ctrlKeyPressed = popOver.isCtrlKeyPressed();
		boolean altKeyPressed = popOver.isAltKeyPressed();
		
		popOver.notifyDragEventListener(new DropzoneDragEvent(e, ctrlKeyPressed, altKeyPressed));

	}
	e.setDropCompleted(success);
	e.consume();
}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:21,代码来源:DropzonePopOverUI.java

示例3: initialize

import javafx.scene.input.Dragboard; //导入依赖的package包/类
@FXML
private void initialize() throws IOException {
  root.getChildren().addListener((ListChangeListener<? super Node>) change -> {
    while (change.next()) {
      for (Node node : change.getAddedSubList()) {
        if (node instanceof WidgetGallery.WidgetGalleryItem) {
          WidgetGallery.WidgetGalleryItem galleryItem = (WidgetGallery.WidgetGalleryItem) node;
          galleryItem.setOnDragDetected(event -> {
            Dragboard dragboard = galleryItem.startDragAndDrop(TransferMode.COPY);

            // TODO type safety
            ClipboardContent clipboard = new ClipboardContent();
            clipboard.put(DataFormats.widgetType, galleryItem.getWidget().getName());
            dragboard.setContent(clipboard);
            event.consume();
          });
        }
      }
    }
  });
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:22,代码来源:WidgetGalleryController.java

示例4: makeLetterDraggable

import javafx.scene.input.Dragboard; //导入依赖的package包/类
/**
 * Adds to the letter the possibility to be dragged on another element.
 *
 * @param letterElement The element to be dragged
 * @param letter        The corresponding letter object
 */
public static void makeLetterDraggable(Node letterElement, LetterInterface letter) {
    // When an user starts to drag a letter
    letterElement.setOnDragDetected(event -> {
        Dragboard dragboard = letterElement.startDragAndDrop(TransferMode.ANY);
        dragboard.setDragView(letterElement.snapshot(null, null));
        letterElement.setVisible(false);

        ClipboardContent clipboardContent = new ClipboardContent();
        clipboardContent.put(LetterInterface.DATA_FORMAT, letter);

        dragboard.setContent(clipboardContent);

        event.consume();
    });

    // When the user has dropped the letter
    letterElement.setOnDragDone(event -> letterElement.setVisible(true));
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:25,代码来源:DraggableLetterManager.java

示例5: decorate

import javafx.scene.input.Dragboard; //导入依赖的package包/类
public Pane decorate(Pane pane) {
    pane.setOnDragOver(evt -> {
        if (evt.getGestureSource() != pane &&
                evt.getDragboard().hasString()) {
            evt.acceptTransferModes(TransferMode.ANY);
        }
        evt.consume();
    });

    pane.setOnDragDropped(evt -> {
        Dragboard db = evt.getDragboard();
        boolean success = false;
        if (db.hasString()) {
            // Create a button and add to pane
            if (!locked) {
                addButton(db.getString(), pane, evt.getScreenX(), evt.getScreenY());
            }
            success = true;
        }
        // Let the source know whether the string was dropped successfully
        evt.setDropCompleted(success);
        evt.consume();
    });

    return pane;
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:27,代码来源:DragPaneDecorator.java

示例6: handleDropped

import javafx.scene.input.Dragboard; //导入依赖的package包/类
@FXML
private void handleDropped(DragEvent event) {
    // ドラッグボードを取得
    Dragboard board = event.getDragboard();
    if (board.hasFiles()) {
        board.getFiles().stream().forEach((f) -> {
            if (f.isDirectory()) {
                List<String> filePathList = new ArrayList<>();
                getFileRecursion(filePathList, f.getAbsolutePath()).stream().filter(s -> isTextFile(s)).collect(Collectors.toList()).forEach(s -> fileList.getItems().add(new Label(s)));
            } else {
                if (isTextFile(f.getAbsolutePath()))
                    fileList.getItems().add(new Label(f.getAbsolutePath()));
            }
        });
        // ドロップ受け入れ
        event.setDropCompleted(true);
    } else {    // ファイル以外なら
        // ドロップ受け入れ拒否
        event.setDropCompleted(false);
    }
}
 
开发者ID:Khromium,项目名称:MakeSourceList4j,代码行数:22,代码来源:Controller.java

示例7: targetSetOnDragDropped

import javafx.scene.input.Dragboard; //导入依赖的package包/类
private void targetSetOnDragDropped(ScreenMap target, DragEvent e) {
	Dragboard db = e.getDragboard();
	boolean success = false;
	if (e.getDragboard().hasImage()) {
		String imageName = db.getString();
		Point2D point = target.sceneToLocal(e.getSceneX(), e.getSceneY());
		GamePoint gameCoords = new GamePoint(point.getX()/target.getScreenWidth(), point.getY()/target.getScreenHeight());
		for (Pair<String, Image> p : myScreenObjects.keySet()) {
			String iName = p.getKey();
			if (imageName.equals(iName)) {
				XStreamHandler xstream = new XStreamHandler();
				File tempSpriteFile = new File("data/tempSprites/tempSprite.xml");
				xstream.saveToFile(myScreenObjects.get(p), tempSpriteFile);
				SpriteMakerModel xmlSprite = (SpriteMakerModel) xstream.getAttributeFromFile(tempSpriteFile);
				xmlSprite.addComponent(new Position(gameCoords, 0)); //heading 0 because all sprites default to this
				myModel.addBackgroundTile(xmlSprite);
				break;
			}
		}
		success = true;
	}
	e.setDropCompleted(success);
	e.consume();
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:25,代码来源:ScreenObjectHolder.java

示例8: dragDropped

import javafx.scene.input.Dragboard; //导入依赖的package包/类
/**
 * Handle dropped files to editor.
 */
@FXThread
private void dragDropped(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);
    if (!canAccept(file)) return;

    handleFile(file);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:19,代码来源:ResourcePropertyEditorControl.java

示例9: dragOver

import javafx.scene.input.Dragboard; //导入依赖的package包/类
/**
 * Handle drag over.
 */
@FXThread
private void dragOver(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);
    if (!canAccept(file)) return;

    final Set<TransferMode> transferModes = dragboard.getTransferModes();
    final boolean isCopy = transferModes.contains(TransferMode.COPY);

    dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE);
    dragEvent.consume();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:ResourcePropertyEditorControl.java

示例10: handleDragDroppedEvent

import javafx.scene.input.Dragboard; //导入依赖的package包/类
/**
 * Handle dropped events.
 *
 * @param dragEvent the dropped event.
 */
@FXThread
private void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);

    if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) {
        return;
    }

    addMaterial(file.toPath());
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:24,代码来源:MaterialPropertyControl.java

示例11: handleDragOverEvent

import javafx.scene.input.Dragboard; //导入依赖的package包/类
/**
 * Handle drag over events.
 *
 * @param dragEvent the drag over event.
 */
@FXThread
private void handleDragOverEvent(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);

    if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) {
        return;
    }

    final Set<TransferMode> transferModes = dragboard.getTransferModes();
    final boolean isCopy = transferModes.contains(TransferMode.COPY);

    dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE);
    dragEvent.consume();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:28,代码来源:MaterialPropertyControl.java

示例12: initializeSetOnDragDetected

import javafx.scene.input.Dragboard; //导入依赖的package包/类
private void initializeSetOnDragDetected() {
//        LoggerFacade.INSTANCE.debug(this.getClass(), "Initialize setOnDragDetected"); // NOI18N
        
        super.setOnDragDetected(event -> {
            if (super.getItem() == null) {
                return;
            }

            final Dragboard dragboard = startDragAndDrop(TransferMode.MOVE);
            final ClipboardContent content = new ClipboardContent();
            content.putString(String.valueOf(super.getItem().getProjectId()));
//            dragboard.setDragView(
//                    birdImages.get(
//                            items.indexOf(
//                                    getItem()
//                            )
//                    )
//            );
            dragboard.setContent(content);
            event.consume();
        });
    }
 
开发者ID:Naoghuman,项目名称:Incubator,代码行数:23,代码来源:ProjectItemCell.java

示例13: initializeSetOnDragDropped

import javafx.scene.input.Dragboard; //导入依赖的package包/类
private void initializeSetOnDragDropped() {
//        LoggerFacade.INSTANCE.debug(this.getClass(), "Initialize setOnDragDropped"); // NOI18N

        super.setOnDragDropped(event -> {
            if (super.getItem() == null) {
                return;
            }

            final Dragboard dragboard = event.getDragboard();
            boolean success = false;
            if (dragboard.hasString()) {
                final List<ProjectItemPresenter> items = this.updateOverview(dragboard);
                this.updateDatabase(items);

                success = true;
            }

            event.setDropCompleted(success);
            event.consume();
        });
    }
 
开发者ID:Naoghuman,项目名称:Incubator,代码行数:22,代码来源:ProjectItemCell.java

示例14: updateOverview

import javafx.scene.input.Dragboard; //导入依赖的package包/类
private List<ProjectItemPresenter> updateOverview(Dragboard dragboard) {
    final ObservableList<ProjectItemPresenter> items = super.getListView().getItems();
    int draggedIndex = items.indexOf(dragboard.getString());
    ProjectItemPresenter draggedItem = null;
    for (ProjectItemPresenter item : items) {
        if (item.getProjectId() == Long.parseLong(dragboard.getString())) {
            draggedItem = item;
            draggedIndex = items.indexOf(item);
            super.getItem().getParent().setOpacity(1.0);
            break;
        }
    }
    final int thisIndex = items.indexOf(getItem());

    items.set(draggedIndex, getItem());
    items.set(thisIndex, draggedItem);

    final List<ProjectItemPresenter> itemsCopy = new ArrayList<>(items);
    super.getListView().getItems().setAll(itemsCopy);
    
    return itemsCopy;
}
 
开发者ID:Naoghuman,项目名称:Incubator,代码行数:23,代码来源:ProjectItemCell.java

示例15: treeProjectFileOnDragDetected

import javafx.scene.input.Dragboard; //导入依赖的package包/类
/**
 * 트리 드래그 디텍트 이벤트 처리. <br/>
 * 트리내에 구성된 파일의 위치정보를 드래그 드롭 기능으로 <br/>
 * 전달해주는 역할을 수행한다.<br/>
 * <br/>
 * 
 * @작성자 : KYJ
 * @작성일 : 2017. 11. 21.
 * @param ev
 */
public void treeProjectFileOnDragDetected(MouseEvent ev) {
	TreeItem<JavaProjectFileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
	if (selectedItem == null || selectedItem.getValue() == null) {
		return;
	}

	File file = selectedItem.getValue().getFile();
	if (file == null || !file.exists())
		return;

	Dragboard board = treeProjectFile.startDragAndDrop(TransferMode.LINK);
	ClipboardContent content = new ClipboardContent();
	content.putFiles(Arrays.asList(file));
	board.setContent(content);

	ev.consume();
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:28,代码来源:SystemLayoutViewController.java


注:本文中的javafx.scene.input.Dragboard类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。