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


Java Dragboard.getString方法代碼示例

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


在下文中一共展示了Dragboard.getString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

示例2: installWidgetsFromString

import javafx.scene.input.Dragboard; //導入方法依賴的package包/類
/**
 * @param event The {@link DragEvent} containing the dragged data.
 * @param selection_tracker Used to get the grid steps from its model to be
 *            used in offsetting multiple widgets.
 * @param widgets The container of the created widgets.
 */
private static void installWidgetsFromString (
    final DragEvent event,
    final SelectedWidgetUITracker selection_tracker,
    final List<Widget> widgets
) {

    final Dragboard db = event.getDragboard();
    final String xmlOrText = db.getString();

    try {
        widgets.addAll(ModelReader.parseXML(xmlOrText).getChildren());
    } catch ( Exception ex ) {
        installWidgetsFromString(event, xmlOrText, selection_tracker, widgets);
    }

}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:23,代碼來源:WidgetTransfer.java

示例3: handleDragDroppedAction

import javafx.scene.input.Dragboard; //導入方法依賴的package包/類
/**
 * handleDragDroppedAction() method.
 *
 * @param argEvent the event handled
 */
@FXML
protected final void handleDragDroppedAction(final DragEvent argEvent) {
    final Dragboard board = argEvent.getDragboard();
    boolean success = false;
    if (board.hasString()) {
        final TreeView target = (TreeView) argEvent.getSource();
        @SuppressWarnings("unchecked") final TreeItem<String> tmp = new TreeItem(board.getString());
        //noinspection unchecked
        target.getRoot().getChildren().add(tmp);
        success = true;
    }
    argEvent.setDropCompleted(success);
    argEvent.consume();
    LOG.info("Drag dropped");
}
 
開發者ID:yeamanan,項目名稱:ProjectTwo,代碼行數:21,代碼來源:SurvivorEditorController.java

示例4: onCaretPosition

import javafx.scene.input.Dragboard; //導入方法依賴的package包/類
static void onCaretPosition(TextInputControl textinput,
		Dragboard dragboard) {
	int caret = textinput.getCaretPosition();
	String insert = dragboard.getString();
	
	String t1 = textinput.getText().substring(0, textinput.getCaretPosition());
	String t2 = textinput.getText().substring(textinput.getCaretPosition(), textinput.getText().length());
	textinput.setText(t1 + insert + t2);
	textinput.positionCaret(caret + insert.length());
}
 
開發者ID:coalang-soft,項目名稱:dragdropfx,代碼行數:11,代碼來源:DnDTextInput.java


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