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