本文整理汇总了Java中javafx.scene.input.Clipboard.getContent方法的典型用法代码示例。如果您正苦于以下问题:Java Clipboard.getContent方法的具体用法?Java Clipboard.getContent怎么用?Java Clipboard.getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.Clipboard
的用法示例。
在下文中一共展示了Clipboard.getContent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
}
示例2: getContent
import javafx.scene.input.Clipboard; //导入方法依赖的package包/类
protected CMap<DataFormat,CList<LineSegment>> getContent(Clipboard clip)
{
Set<DataFormat> formats = clip.getContentTypes();
CMap<DataFormat,CList<LineSegment>> rv = new CMap<>(formats.size());
for(DataFormat f: formats)
{
Object x = clip.getContent(f);
CList<LineSegment> segments = createSegments(f, x);
rv.put(f, segments);
}
return rv;
}
示例3: pasteClipboard
import javafx.scene.input.Clipboard; //导入方法依赖的package包/类
/**
* paste into table
*/
public void pasteClipboard() {
final Clipboard clipboard = Clipboard.getSystemClipboard();
if (clipboard.getContent(fmt) != null) {
spreadsheetView.pasteClipboard();
} else {
String contents = clipboard.getString().trim().replaceAll("\r\n", "\n").replaceAll("\r", "\n");
String[] lines = contents.split("\n");
paste(lines);
}
}
示例4: paste
import javafx.scene.input.Clipboard; //导入方法依赖的package包/类
public void paste() {
if(mode == Mode.EDIT_MODE) {
Clipboard clipboard = Clipboard.getSystemClipboard();
String clip = (String) clipboard.getContent(DataFormat.PLAIN_TEXT);
if (clip != null) {
jsEditor.call("insert", clip);
}
setEdited(true);
}
}
示例5: pasteResources
import javafx.scene.input.Clipboard; //导入方法依赖的package包/类
@FXML
public void pasteResources() {
ObservableList<ResourceItem> items = fileExplorer.getSelectedItems();
Iterator<ResourceItem> it = items.iterator();
if (it.hasNext()) {
ResourceItem first = it.next();
Path parent = getDirectory(first);
Clipboard clipboard = Clipboard.getSystemClipboard();
List<File> files = clipboard.getFiles();
Object cut = clipboard.getContent(CUT);
for (File file : files) {
Path source = file.toPath();
Path target = parent.resolve(file.getName());
try {
if (cut instanceof Boolean && ((Boolean) cut).booleanValue()) {
Files.move(source, target);
} else {
List<Path> children = Files.walk(source).sorted().collect(Collectors.toList());
for (Path child : children) {
Files.copy(child, target.resolve(source.relativize(child)));
}
}
} catch (IOException ex) {
handleException(ex);
}
}
}
}
示例6: paste
import javafx.scene.input.Clipboard; //导入方法依赖的package包/类
/**
* Inserts the content from the clipboard into this text-editing area,
* replacing the current selection. If there is no selection, the content
* from the clipboard is inserted at the current caret position.
*/
default void paste() {
Clipboard clipboard = Clipboard.getSystemClipboard();
if(getStyleCodecs().isPresent()) {
Tuple2<Codec<PS>, Codec<StyledSegment<SEG, S>>> codecs = getStyleCodecs().get();
Codec<StyledDocument<PS, SEG, S>> codec = ReadOnlyStyledDocument.codec(codecs._1, codecs._2, getSegOps());
DataFormat format = dataFormat(codec.getName());
if(clipboard.hasContent(format)) {
byte[] bytes = (byte[]) clipboard.getContent(format);
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
DataInputStream dis = new DataInputStream(is);
StyledDocument<PS, SEG, S> doc = null;
try {
doc = codec.decode(dis);
} catch (IOException e) {
System.err.println("Codec error: Failed to decode '" + codec.getName() + "':");
e.printStackTrace();
}
if(doc != null) {
replaceSelection(doc);
return;
}
}
}
if (clipboard.hasString()) {
String text = clipboard.getString();
if (text != null) {
replaceSelection(text);
}
}
}