當前位置: 首頁>>代碼示例>>Java>>正文


Java DragEvent.setDropCompleted方法代碼示例

本文整理匯總了Java中javafx.scene.input.DragEvent.setDropCompleted方法的典型用法代碼示例。如果您正苦於以下問題:Java DragEvent.setDropCompleted方法的具體用法?Java DragEvent.setDropCompleted怎麽用?Java DragEvent.setDropCompleted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.input.DragEvent的用法示例。


在下文中一共展示了DragEvent.setDropCompleted方法的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: onDragDropped

import javafx.scene.input.DragEvent; //導入方法依賴的package包/類
/**
 * Drag dropped to the file drop area.
 *
 * @param event
 *            Event data.
 */
public final void onDragDropped(final DragEvent event) throws IOException {
    boolean success = false;
    LOG.log(Level.FINE, "Drag dropped: " + event.getDragboard().getString());
    if (event.getDragboard().hasFiles()) {
        File file = event.getDragboard().getFiles().get(0);
        // Check if file has a valid extension
        if (file.getName().endsWith(".bin")) {
            openSimulationFile(file);
            success = true;
        } else {
            String message = "Incorrect extension of the opened file (required .bin)";
            Dialog.createExceptionDialog(message, new IllegalArgumentException(message));
        }
    }
    event.setDropCompleted(success);
    event.consume();
}
 
開發者ID:gim-,項目名稱:particles-in-box-java,代碼行數:24,代碼來源:NewExperimentController.java

示例5: dragDropped

import javafx.scene.input.DragEvent; //導入方法依賴的package包/類
/**
 * Drag dropped action
 * 
 * @param event
 */
@FXML
public void dragDropped(DragEvent event) {		
   	try {
		loadConfig(event.getDragboard().getFiles().get(0));
	} catch (Exception e) {
		// TODO Auto-generated catch block
		Alert alert = new Alert(Alert.AlertType.ERROR);
		alert.setTitle("Import");
		alert.setHeaderText("Loading error");
		alert.setContentText(e.getMessage());
		alert.initModality(Modality.WINDOW_MODAL);
		alert.showAndWait();
		e.printStackTrace();
		return;
	}
      
	menuController.selectExerciseOverview();
   	event.setDropCompleted(true);
       event.consume();
}
 
開發者ID:ProPra16,項目名稱:programmierpraktikum-abschlussprojekt-null,代碼行數:26,代碼來源:ImportViewController.java

示例6: 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

示例7: 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

示例8: handle

import javafx.scene.input.DragEvent; //導入方法依賴的package包/類
@Override
  public void handle(DragEvent event) {
      Dragboard dragboard = event.getDragboard();
      Object source = event.getSource();
      // Look for the viewer that we dragged on to - may be null, if drag was on
      QuPathViewer viewer = null;
      for (QuPathViewer viewer2 : gui.getViewers()) {
      	if (viewer2.getView() == source) {
      		viewer = viewer2;
      		break;
      	}
      }
      // If only one viewer is available, there is no ambiguity... use it
      if (viewer == null && gui.getViewers().size() == 1)
      	viewer = gui.getViewer();
      
if (dragboard.hasFiles()) {
       logger.debug("Files dragged onto {}", source);
	handleFileDrop(viewer, dragboard.getFiles());
}
event.setDropCompleted(true);
event.consume();
  }
 
開發者ID:qupath,項目名稱:qupath,代碼行數:24,代碼來源:DragDropFileImportListener.java

示例9: 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

示例10: dropOnSourcePallet

import javafx.scene.input.DragEvent; //導入方法依賴的package包/類
private void dropOnSourcePallet(DragEvent event, int sourcePalletId) {
	event.setDropCompleted(true);
	TextInputDialog addBlocksDialog = new TextInputDialog();
	addBlocksDialog.setTitle("Add Blocks");
	addBlocksDialog.setHeaderText("Enter the amount of blocks you want to add");
	Optional<String> result = addBlocksDialog.showAndWait();
	result.ifPresent(count -> sourcePallets[sourcePalletId] += Integer.parseInt(count));
	
	String stateImagePath;
	if (sourcePallets[sourcePalletId] <= 5) {
		stateImagePath = "images/blocks-almost-empty.png";
	} else if (sourcePallets[sourcePalletId] > 5 && sourcePallets[sourcePalletId] <= 15) {
		stateImagePath = "images/blocks-normal.png";
	} else if (sourcePallets[sourcePalletId] > 15) {
		stateImagePath = "images/blocks-full.png";
	} else {
		stateImagePath = "";
	}
	Image stateImage = new Image(getClass().getResource(stateImagePath).toString());
	((BorderPane) event.getSource()).setCenter(new ImageView(stateImage));
	
	System.out.println(Arrays.toString(sourcePallets));
	event.consume();
}
 
開發者ID:gseteamproject,項目名稱:gseproject,代碼行數:25,代碼來源:TrackManagerController.java

示例11: 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

示例12: onDragDroppedHandleFiles

import javafx.scene.input.DragEvent; //導入方法依賴的package包/類
public void onDragDroppedHandleFiles(DragEvent event){
    Dragboard db = event.getDragboard();
    boolean success = false;
    if (db.hasFiles()) {
        success = true;
        for (File file : db.getFiles()) {
            showManifest(file);
            break;
        }
    }
    event.setDropCompleted(success);
    event.consume();
}
 
開發者ID:linchaolong,項目名稱:ApkToolPlus,代碼行數:14,代碼來源:ApkInfoPrinterActivity.java

示例13: mouseDragDropped

import javafx.scene.input.DragEvent; //導入方法依賴的package包/類
private void mouseDragDropped (final DragEvent event) {
    Dragboard db = event.getDragboard();
    boolean success = false;
    if (db.hasContent(VoogaFileFormat.getInstance())) {
        VoogaFile node = (VoogaFile) db.getContent(VoogaFileFormat.getInstance());
        if (node.getType() != VoogaFileType.FOLDER) {
            if (node.getType() != VoogaFileType.ARCHETYPE &&
                node.getType() != VoogaFileType.GAME_OBJECT) {
                if (elementManager.hasElement(node.getPath())) {
                    moveElement(node.getPath(), event);
                }
                else {
                    addElement(node, event, "");
                }
            }
            else {
                if (node.getType() == VoogaFileType.ARCHETYPE) {
                    addElement(node, event, node.toString());
                }
            }
        }
        success = true;
    }

    if (db.hasString()) {
        Node object = (Node) elementManager.getElement(db.getString());
        object.setTranslateX(event.getX() - x_offset);
        object.setTranslateY(event.getY() - y_offset);
    }

    event.setDropCompleted(success);
}
 
開發者ID:sjain28,項目名稱:Game-Engine-Vooga,代碼行數:33,代碼來源:DesignBoard.java

示例14: onDragDropped

import javafx.scene.input.DragEvent; //導入方法依賴的package包/類
@Override
public void onDragDropped(DragEvent ev) {
	if (ev.isConsumed())
		return;

	if (ev.getDragboard().hasFiles()) {

		List<File> files = ev.getDragboard().getFiles();

		// tbDatabase.getItems().add(e)
		files.stream().findFirst().ifPresent(f -> {

			if (f.length() > dragDropLimitSize()) {

				DialogUtil.showMessageDialog("파일 용량이 너무 큽니다.");
				return;

			}

			String encoding = "UTF-8";
			try {
				encoding = FileUtil.findEncoding(f);
			} catch (IOException e1) {
				// Not Important.
			}

			try (FileInputStream is = new FileInputStream(f)) {
				setContent(FileUtil.readToString(is, encoding));
			} catch (Exception e) {
				LOGGER.error(ValueUtil.toString(e));
			}

		});

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

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:40,代碼來源:CodeAreaFileDragDropHelper.java

示例15: onDragDropped

import javafx.scene.input.DragEvent; //導入方法依賴的package包/類
@Override
public void onDragDropped(DragEvent ev) {

	if (ev.isConsumed())
		return;

	if (ev.getDragboard().hasFiles()) {

		List<File> files = ev.getDragboard().getFiles();

		// tbDatabase.getItems().add(e)
		files.stream().filter(f -> f.getName().endsWith(".wib")).findFirst().ifPresent(f -> {

			BehaviorReader reader = new BehaviorReader(f);
			setContent(reader.readBehavior());
			// String encoding = "UTF-8";
			// try {
			// encoding = FileUtil.findEncoding(f);
			// } catch (IOException e1) {
			// // Not Important.
			// }
			//
			// try (FileInputStream is = new FileInputStream(f)) {
			// setContent(FileUtil.readToString(is, encoding));
			// } catch (Exception e) {
			// LOGGER.error(ValueUtil.toString(e));
			// }

		});

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

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:36,代碼來源:BehaviorCodeAreaFileDragDropHelper.java


注:本文中的javafx.scene.input.DragEvent.setDropCompleted方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。