本文整理汇总了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();
}
示例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);
}
}
示例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");
}
示例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());
}