本文整理汇总了Java中javafx.scene.input.Clipboard类的典型用法代码示例。如果您正苦于以下问题:Java Clipboard类的具体用法?Java Clipboard怎么用?Java Clipboard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Clipboard类属于javafx.scene.input包,在下文中一共展示了Clipboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import javafx.scene.input.Clipboard; //导入依赖的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;
}
示例2: setMenuItemDefaultActions
import javafx.scene.input.Clipboard; //导入依赖的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);
});
});
}
示例3: fillContextMenu
import javafx.scene.input.Clipboard; //导入依赖的package包/类
/**
* Fill the items actions for this node.
*
* @param nodeTree the node tree
* @param items the items
*/
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) {
if (canEditName()) items.add(new RenameNodeAction(nodeTree, this));
if (canCopy()) items.add(new CopyNodeAction(nodeTree, this));
final Clipboard clipboard = Clipboard.getSystemClipboard();
final Object content = clipboard.getContent(DATA_FORMAT);
if (!(content instanceof Long)) {
return;
}
final Long objectId = (Long) content;
final TreeItem<?> treeItem = UIUtils.findItem(nodeTree.getTreeView(), objectId);
final TreeNode<?> treeNode = treeItem == null ? null : (TreeNode<?>) treeItem.getValue();
if (treeNode != null && canAccept(treeNode, true)) {
items.add(new PasteNodeAction(nodeTree, this, treeNode));
}
}
示例4: execute
import javafx.scene.input.Clipboard; //导入依赖的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);
}
示例5: execute
import javafx.scene.input.Clipboard; //导入依赖的package包/类
@FXThread
@Override
protected void execute(@Nullable final ActionEvent event) {
super.execute(event);
final Clipboard clipboard = Clipboard.getSystemClipboard();
if (clipboard == null) return;
final List<File> files = unsafeCast(clipboard.getContent(DataFormat.FILES));
if (files == null || files.isEmpty()) return;
final Path currentFile = getElement().getFile();
final boolean isCut = "cut".equals(clipboard.getContent(EditorUtil.JAVA_PARAM));
if (isCut) {
files.forEach(file -> moveFile(currentFile, file.toPath()));
} else {
files.forEach(file -> copyFile(currentFile, file.toPath()));
}
clipboard.clear();
}
示例6: execute
import javafx.scene.input.Clipboard; //导入依赖的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);
}
示例7: keyOnPressd
import javafx.scene.input.Clipboard; //导入依赖的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();
}
}
示例8: pasteHandler
import javafx.scene.input.Clipboard; //导入依赖的package包/类
/**
* 붙여넣기 핸들링 <br/>
*
* 10.26 이미지 붙여넣기
*
* @작성자 : KYJ
* @작성일 : 2017. 10. 26.
* @param ev
*/
protected void pasteHandler(KeyEvent ev) {
Clipboard systemClipboard = Clipboard.getSystemClipboard();
Set<DataFormat> contentTypes = systemClipboard.getContentTypes();
LOGGER.debug("{}", contentTypes);
List<File> files = systemClipboard.getFiles();
if (systemClipboard.getImage() != null) {
pasteImage(systemClipboard.getImage());
} else if (files != null) {
for (File f : files) {
try {
String contentType = Files.probeContentType(f.toPath());
LOGGER.debug(contentType);
if (contentType.startsWith("image/")) {
pasteImage(contentType, FileUtil.getBytes(f));
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
示例9: cutSelectionToClipboard
import javafx.scene.input.Clipboard; //导入依赖的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;
}
示例10: copyValue
import javafx.scene.input.Clipboard; //导入依赖的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);
}
}
}
示例11: createRightPane
import javafx.scene.input.Clipboard; //导入依赖的package包/类
private Parent createRightPane() {
HBox hbox = new HBox(10);
VBox lbox = new VBox(10);
lbox.getChildren().addAll(targetControlPane, new Separator(), new Text("Target control type:"),
createControlCombo(targetControlPane, false), new Text("Target transfer modes:"), createTMSelect(targetModes));
VBox rbox = new VBox(10);
rbox.getChildren().addAll(new Text("Data formats:"), createFormatSelect(targetFormats),
ButtonBuilder.create().text("paste from clipboard").id(ID_FROM_CLIPBOARD_BUTTON).onAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
getDataFromClipboard(Clipboard.getSystemClipboard());
}
}).build());
VBox content = new VBox(10);
content.getChildren().addAll(new Text("Transfered content:"), transferedContentPane);
hbox.getChildren().addAll(lbox, new Separator(Orientation.VERTICAL), rbox,
new Separator(Orientation.VERTICAL), content);
if (parameters.size() > 0) {
hbox.setStyle("-fx-background-color: " + parameters.get(0) + ";");
}
return hbox;
}
示例12: initialize
import javafx.scene.input.Clipboard; //导入依赖的package包/类
@FXML
public void initialize() {
copyBtn.setOnAction(e -> {
final ClipboardContent content = new ClipboardContent();
content.putString(textArea.getText());
Clipboard.getSystemClipboard().setContent(content);
});
// Select the entire URL on focus gain
wowheadUrl.focusedProperty().addListener((ChangeListener<Boolean>) (value, oldValue, newValue) -> {
if (newValue) {
Platform.runLater(wowheadUrl::selectAll);
}
});
supportedArticleTypes.setText("Supported article types: "
+ Stream.of(ParserType.values()).map(Object::toString).collect(Collectors.joining(", ")));
}
示例13: copy2clipboard
import javafx.scene.input.Clipboard; //导入依赖的package包/类
private void copy2clipboard(TableView source) {
StringBuilder out = new StringBuilder();
ObservableList<Integer> selectedCells = source.getSelectionModel().getSelectedIndices();
int columns = source.getColumns().size();
for (Integer row : selectedCells) {
for (int idx = 0; idx < columns; idx++) {
TableColumn tc = (TableColumn) source.getColumns().get(idx);
Object item = tc.getCellData((int) row);
out.append(item.toString());
if (idx != columns - 1) {
out.append('\t');
}
}
out.append("\n");
}
ClipboardContent clipboardContent = new ClipboardContent();
clipboardContent.putString(out.toString());
Clipboard.getSystemClipboard().setContent(clipboardContent);
}
示例14: onCmdCopyEntry
import javafx.scene.input.Clipboard; //导入依赖的package包/类
@SuppressWarnings("unused")
@FXML
void onCmdCopyEntry(ActionEvent evt) {
UserCertStoreEntry entry = getSelectedStoreEntry();
if (entry != null) {
List<Path> entryFilePaths = entry.getFilePaths();
if (!entryFilePaths.isEmpty()) {
List<File> entryFiles = entryFilePaths.stream().map((p) -> p.toFile()).collect(Collectors.toList());
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putFiles(entryFiles);
clipboard.setContent(content);
}
}
}
示例15: onCmdCopyEntryAttributes
import javafx.scene.input.Clipboard; //导入依赖的package包/类
@SuppressWarnings("unused")
@FXML
void onCmdCopyEntryAttributes(ActionEvent evt) {
TreeItem<AttributeModel> rootItem = this.ctlDetailsView.getRoot();
if (rootItem != null) {
StringWriter buffer = new StringWriter();
PrintWriter writer = new PrintWriter(buffer);
for (TreeItem<AttributeModel> attributeItem : rootItem.getChildren()) {
copyEntryAttributesHelper(writer, attributeItem, "");
}
writer.flush();
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(buffer.toString());
clipboard.setContent(content);
}
}