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


Java DragEvent.getDragboard方法代码示例

本文整理汇总了Java中javafx.scene.input.DragEvent.getDragboard方法的典型用法代码示例。如果您正苦于以下问题:Java DragEvent.getDragboard方法的具体用法?Java DragEvent.getDragboard怎么用?Java DragEvent.getDragboard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.input.DragEvent的用法示例。


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

示例1: mouseDragDropped

import javafx.scene.input.DragEvent; //导入方法依赖的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

示例2: handleDropped

import javafx.scene.input.DragEvent; //导入方法依赖的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

示例3: targetSetOnDragDropped

import javafx.scene.input.DragEvent; //导入方法依赖的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

示例4: dragDropped

import javafx.scene.input.DragEvent; //导入方法依赖的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

示例5: dragOver

import javafx.scene.input.DragEvent; //导入方法依赖的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

示例6: handleDragDroppedEvent

import javafx.scene.input.DragEvent; //导入方法依赖的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

示例7: handleDragOverEvent

import javafx.scene.input.DragEvent; //导入方法依赖的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

示例8: handleDragDropped

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
private void handleDragDropped(DragEvent event) {
    LOGGER.debug("drag dropped");

    Dragboard dragboard = event.getDragboard();
    boolean success = dragboard.hasString();
    if (success) {
        try {
            int slideId = Integer.parseInt(dragboard.getString());
            LOGGER.debug("dropped slide with id {} on divider", slideId);

            if (slideDroppedCallback != null) {
                slideDroppedCallback.accept(slideId);
            }
        } catch (NumberFormatException ex) {
            success = false;
        }

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

示例9: handleRowDragDropped

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
protected void handleRowDragDropped(TreeTableRow<T> r, DragEvent ev)
{
	Dragboard db = ev.getDragboard();
	if(isAcceptable(db, r))
	{
		int ix = (Integer)db.getContent(JAVA_DATA_FORMAT);
		TreeItem item = tree.getTreeItem(ix);
		item.getParent().getChildren().remove(item);
		getTarget(r).getChildren().add(item);
		ev.setDropCompleted(true);
		
		tree.getSelectionModel().clearSelection();
		tree.getSelectionModel().select(item);
		// FIX focus and selection differ after this
		
		ev.consume();
	}
}
 
开发者ID:andy-goryachev,项目名称:ReqTraq,代码行数:19,代码来源:TreeTableHandler.java

示例10: mouseDragOver

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
@FXML void mouseDragOver(final DragEvent e) {
    final Dragboard db = e.getDragboard();
 
    final boolean isAccepted = db.getFiles().get(0).getName().toLowerCase().endsWith(".log")
            || db.getFiles().get(0).getName().toLowerCase().endsWith(".txt");
 
    if (db.hasFiles()) {
        if (isAccepted) {
            tabpane.setStyle("-fx-border-color: red;"
          + "-fx-border-width: 5;"
          + "-fx-background-color: #C6C6C6;"
          + "-fx-border-style: solid;");//TODO move to css
            e.acceptTransferModes(TransferMode.COPY);
        }
    } else {
        e.consume();
    }
}
 
开发者ID:bkusche,项目名称:bktail2,代码行数:19,代码来源:TabbedMainController.java

示例11: onDragOver

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
private void onDragOver(final TreeTableRow<GPXLineItem> row, final DragEvent event) {
    Dragboard db = event.getDragboard();
    if (db.getContent(SERIALIZED_MIME_TYPE) != null) {
        if (!row.isEmpty()) {
            event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
            event.consume();
        }
    } else {
        if (db.hasFiles()) {
            for (File file:db.getFiles()) {
                // accept only gpx files
                if (GPXEditorWorker.GPX_EXT.equals(FilenameUtils.getExtension(file.getName()).toLowerCase())) {
                    event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
                    break;
                }
            }
        } else {
            event.consume();
        }
    }
}
 
开发者ID:ThomasDaheim,项目名称:GPXEditor,代码行数:22,代码来源:GPXTreeTableView.java

示例12: songPathDragDropped

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
@FXML
public void songPathDragDropped(final DragEvent ev) {
	Dragboard db = ev.getDragboard();
	if (db.hasFiles()) {
		for (File f : db.getFiles()) {
			if (f.isDirectory()) {
				boolean unique = true;
				for (String path : bmsroot.getItems()) {
					if (path.equals(f.getPath()) || f.getPath().startsWith(path + File.separatorChar)) {
						unique = false;
						break;
					}
				}
				if (unique) {
					bmsroot.getItems().add(f.getPath());
				}
			}
		}
	}
}
 
开发者ID:exch-bms2,项目名称:beatoraja,代码行数:21,代码来源:PlayConfigurationView.java

示例13: handle

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
@Override
public void handle(DragEvent event) {
  if (event.getEventType() == DragEvent.DRAG_OVER) {
    if (event.getDragboard().hasFiles()) {
      event.acceptTransferModes(TransferMode.COPY);
    }
    event.consume();
  } else if (event.getEventType() == DragEvent.DRAG_DROPPED) {
    boolean isTransferDone = false;
    List<File> files = new ArrayList<>();
    Dragboard dragBoard = event.getDragboard();
    if (dragBoard.hasFiles()) {
      isTransferDone = true;
      files = dragBoard.getFiles();
    }
    event.setDropCompleted(isTransferDone);
    event.consume();
    try {
      this.controller.filesDropped(files);
    } catch (Exception ex) {
      new ExceptionAlert().showAndWait(null, ex);
    }
  }
}
 
开发者ID:adakitesystems,项目名称:DropLauncher,代码行数:25,代码来源:View.java

示例14: onDragDropped

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
@Override
protected void onDragDropped(DragEvent e) {
    Dragboard db = e.getDragboard();
    if (db.hasContent(DataFormatConstants.COMPONENT_ENTITY)) {
        ComponentDefine c = (ComponentDefine) db.getContent(DataFormatConstants.COMPONENT_ENTITY);
        e.setDropCompleted(true);
        e.consume();

        // 当拖动物体到3D场景的时候必须把JFX中的鼠标坐标转到到JME中的坐标.
        // 不能直接用jme场景中获取鼠标坐标的方式,因为JME是放在awt canvas上的,这时还未获得焦点,直接用
        // JME中的方式获取鼠标坐标会错位。
        lastDragXPos = e.getX();
        lastDragYPos = e.getY();

        // 必须隔一帧,即等拖放操作完成执行后再弹窗.
        // 这里不能直接执行CustomDialog,因为当CustomDialog为模态时会锁住窗口,这会导致当第二次拖放操作时发生:
        // Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: 
        // Key already associated with a running event loop: [email protected]
        Jfx.runOnJfx(() -> {
            ComponentManager.createComponent(c, this);
        });
    }
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:24,代码来源:JfxSceneEdit.java

示例15: handle

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
public void handle(DragEvent event) {
    Dragboard dragboard = event.getDragboard();
    if (dragboard.hasFiles()){
        try {
            File file = dragboard.getFiles().get(0);
            if (file != null) {
                textField.setText(file.getAbsolutePath());
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
 
开发者ID:F8LEFT,项目名称:FApkSigner,代码行数:14,代码来源:Controller.java


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