本文整理匯總了Java中javafx.scene.input.ClipboardContent類的典型用法代碼示例。如果您正苦於以下問題:Java ClipboardContent類的具體用法?Java ClipboardContent怎麽用?Java ClipboardContent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ClipboardContent類屬於javafx.scene.input包,在下文中一共展示了ClipboardContent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setOnDragDetected
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
/**
* When the dragging is detected, we place the content of the LabelCell
* in the DragBoard.
*/
void setOnDragDetected() {
setOnDragDetected(event -> {
boolean isParentTask = getTreeItem().getParent().equals(root);
boolean isEmpty = getTreeItem().getValue().getText().equals("");
if (!isEmpty && isParentTask) {
Dragboard db = startDragAndDrop(TransferMode.MOVE);
ClipboardContent content = new ClipboardContent();
content.put(controller.DATA_FORMAT, getTreeItem()
.getValue());
db.setContent(content);
}
event.consume();
});
}
示例2: initialize
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
@FXML
private void initialize() throws IOException {
root.getChildren().addListener((ListChangeListener<? super Node>) change -> {
while (change.next()) {
for (Node node : change.getAddedSubList()) {
if (node instanceof WidgetGallery.WidgetGalleryItem) {
WidgetGallery.WidgetGalleryItem galleryItem = (WidgetGallery.WidgetGalleryItem) node;
galleryItem.setOnDragDetected(event -> {
Dragboard dragboard = galleryItem.startDragAndDrop(TransferMode.COPY);
// TODO type safety
ClipboardContent clipboard = new ClipboardContent();
clipboard.put(DataFormats.widgetType, galleryItem.getWidget().getName());
dragboard.setContent(clipboard);
event.consume();
});
}
}
}
});
}
示例3: makeLetterDraggable
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
/**
* Adds to the letter the possibility to be dragged on another element.
*
* @param letterElement The element to be dragged
* @param letter The corresponding letter object
*/
public static void makeLetterDraggable(Node letterElement, LetterInterface letter) {
// When an user starts to drag a letter
letterElement.setOnDragDetected(event -> {
Dragboard dragboard = letterElement.startDragAndDrop(TransferMode.ANY);
dragboard.setDragView(letterElement.snapshot(null, null));
letterElement.setVisible(false);
ClipboardContent clipboardContent = new ClipboardContent();
clipboardContent.put(LetterInterface.DATA_FORMAT, letter);
dragboard.setContent(clipboardContent);
event.consume();
});
// When the user has dropped the letter
letterElement.setOnDragDone(event -> letterElement.setVisible(true));
}
示例4: call
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
@Override
protected String call() throws Exception {
final String url = PictureUploadUtil.getUrl(file.getAbsolutePath());
Platform.runLater(() -> {
labelHint.setText("");
Alert alert = new Alert(
Alert.AlertType.INFORMATION,
url,
new ButtonType("複製到剪切板", ButtonBar.ButtonData.YES)
);
alert.setTitle("上傳成功");
alert.setHeaderText(null);
Optional<ButtonType> buttonType = alert.showAndWait();
if (buttonType.get().getButtonData().equals(ButtonBar.ButtonData.YES)) {
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent cc = new ClipboardContent();
cc.putString(url);
clipboard.setContent(cc);
}
});
return url;
}
示例5: setMenuItemDefaultActions
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
private void setMenuItemDefaultActions() {
connectMenuItem.setOnAction(__ -> {
getFirstIfAnythingSelected().ifPresent(server -> GTAController.tryToConnect(server.getAddress(), server.getPort()));
});
visitWebsiteMenuItem.setOnAction(__ -> getFirstIfAnythingSelected().ifPresent(server -> OSUtility.browse(server.getWebsite())));
addToFavouritesMenuItem.setOnAction(__ -> {
final List<SampServer> serverList = getSelectionModel().getSelectedItems();
serverList.forEach(FavouritesController::addServerToFavourites);
});
removeFromFavouritesMenuItem.setOnAction(__ -> deleteSelectedFavourites());
copyIpAddressAndPortMenuItem.setOnAction(__ -> {
final Optional<SampServer> serverOptional = getFirstIfAnythingSelected();
serverOptional.ifPresent(server -> {
final ClipboardContent content = new ClipboardContent();
content.putString(server.getAddress() + ":" + server.getPort());
Clipboard.getSystemClipboard().setContent(content);
});
});
}
示例6: execute
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
@FXThread
@Override
protected void execute(@Nullable final ActionEvent event) {
super.execute(event);
final Array<ResourceElement> elements = getElements();
final Array<Path> files = ArrayFactory.newArray(Path.class, elements.size());
elements.forEach(files, (resource, toStore) -> toStore.add(resource.getFile()));
final ClipboardContent content = new ClipboardContent();
EditorUtil.addCopiedFile(files, content);
final Clipboard clipboard = Clipboard.getSystemClipboard();
clipboard.setContent(content);
}
示例7: execute
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
@FXThread
@Override
protected void execute(@Nullable final ActionEvent event) {
super.execute(event);
final List<File> files = getElements().stream()
.map(ResourceElement::getFile)
.map(Path::toFile)
.collect(toList());
final ClipboardContent content = new ClipboardContent();
content.putFiles(files);
content.put(EditorUtil.JAVA_PARAM, "cut");
final Clipboard clipboard = Clipboard.getSystemClipboard();
clipboard.setContent(content);
}
示例8: initializeSetOnDragDetected
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
private void initializeSetOnDragDetected() {
// LoggerFacade.INSTANCE.debug(this.getClass(), "Initialize setOnDragDetected"); // NOI18N
super.setOnDragDetected(event -> {
if (super.getItem() == null) {
return;
}
final Dragboard dragboard = startDragAndDrop(TransferMode.MOVE);
final ClipboardContent content = new ClipboardContent();
content.putString(String.valueOf(super.getItem().getProjectId()));
// dragboard.setDragView(
// birdImages.get(
// items.indexOf(
// getItem()
// )
// )
// );
dragboard.setContent(content);
event.consume();
});
}
示例9: treeProjectFileOnDragDetected
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
/**
* 트리 드래그 디텍트 이벤트 처리. <br/>
* 트리내에 구성된 파일의 위치정보를 드래그 드롭 기능으로 <br/>
* 전달해주는 역할을 수행한다.<br/>
* <br/>
*
* @작성자 : KYJ
* @작성일 : 2017. 11. 21.
* @param ev
*/
public void treeProjectFileOnDragDetected(MouseEvent ev) {
TreeItem<JavaProjectFileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
if (selectedItem == null || selectedItem.getValue() == null) {
return;
}
File file = selectedItem.getValue().getFile();
if (file == null || !file.exists())
return;
Dragboard board = treeProjectFile.startDragAndDrop(TransferMode.LINK);
ClipboardContent content = new ClipboardContent();
content.putFiles(Arrays.asList(file));
board.setContent(content);
ev.consume();
}
示例10: keyOnPressd
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
private void keyOnPressd(KeyEvent e) {
if (e.isControlDown() && e.getCode() == KeyCode.C) {
if (e.isConsumed())
return;
ObservableList<TreeItem<XMLMeta>> items = this.getSelectionModel().getSelectedItems();
Clipboard c = Clipboard.getSystemClipboard();
ClipboardContent cc = new ClipboardContent();
StringBuffer sb = new StringBuffer();
for (TreeItem<XMLMeta> item : items) {
sb.append(item.getValue().getText()).append("\n");
}
cc.putString(sb.toString());
c.setContent(cc);
e.consume();
}
}
示例11: CodeAreaClipboardItemListView
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
public CodeAreaClipboardItemListView() {
// List<ClipboardContent> clipBoardItems = parent.getClipBoardItems();
setCellFactory(TextFieldListCell.forListView(new StringConverter<ClipboardContent>() {
@Override
public String toString(ClipboardContent object) {
return object.getString();
}
@Override
public ClipboardContent fromString(String string) {
return null;
}
}));
setOnKeyPressed(this::onKeyPress);
setOnMouseClicked(this::onMouseClick);
}
示例12: onKeyPress
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
void onKeyPress(KeyEvent e) {
if (e.getCode() == KeyCode.ESCAPE) {
if (e.isConsumed())
return;
if (this.window != null) {
this.window.hide();
}
e.consume();
} else if (e.getCode() == KeyCode.ENTER) {
if (e.isConsumed())
return;
ClipboardContent selectedItem = getSelectionModel().getSelectedItem();
if (selectItemAction(selectedItem))
this.window.hide();
e.consume();
}
}
示例13: cutSelectionToClipboard
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
/**
* Get table selection and copy it to the clipboard.
* @param table
* @return
*/
private ObservableList<CsvData> cutSelectionToClipboard(TableView<CsvData> table) {
StringBuilder clipboardString = new StringBuilder();
ObservableList<CsvData> tmpData = table.getSelectionModel().getSelectedItems();
int colNum = CSVmanager.getColNums()-1;
String text;
if (tmpData != null) {
for (int i=0;i<tmpData.size();i++) {
for(int k=0;k<colNum;k++) {
text = tmpData.get(i).getDataValue(k, i);
clipboardString.append(text);
clipboardString.append(",");
}
clipboardString.append("\n");
}
// create clipboard content
final ClipboardContent clipboardContent = new ClipboardContent();
clipboardContent.putString(clipboardString.toString());
// set clipboard content
Clipboard.getSystemClipboard().setContent(clipboardContent);
}
return tmpData;
}
示例14: handle
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
@Override
public void handle(final MouseEvent event) {
final Pane pane = (Pane) event.getSource();
final ImageView view = (ImageView) pane.getChildren().get(0);
final Dragboard db = view.startDragAndDrop(TransferMode.COPY);
final ClipboardContent content = new ClipboardContent();
content.putString(view.getId());
final ComponentPane componentPane = loadComponent(pane.getChildren().get(0).getId().toLowerCase());
workspace.getChildren().add(componentPane);
componentPane.applyCss();
final WritableImage w = componentPane.snapshot(null,null);
workspace.getChildren().remove(componentPane);
content.putImage(w);
db.setContent(content);
event.consume();
}
示例15: copyValue
import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
@FXML
void copyValue() {
if (!tableTree.isFocused()) {
return;
}
TreeItem<ReferenceDescription> item = tableTree.getSelectionModel().getSelectedItem();
if (item != null && item.getValue() != null) {
try {
StringWriter writer = new StringWriter();
XmlEncoder encoder = new XmlEncoder();
encoder.setOutput(writer);
writer.write("<ReferenceDescription>");
ReferenceDescription.encode(item.getValue(), encoder);
writer.write("</ReferenceDescription>");
writer.flush();
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(writer.toString());
clipboard.setContent(content);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}