本文整理匯總了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());
}