当前位置: 首页>>代码示例>>Java>>正文


Java Clipboard.getContent方法代码示例

本文整理汇总了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));
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:TreeNode.java

示例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;
}
 
开发者ID:andy-goryachev,项目名称:FxEditor,代码行数:13,代码来源:ClipboardDemoPane.java

示例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);
    }
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:14,代码来源:SamplesSpreadSheet.java

示例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);
	}
}
 
开发者ID:mbway,项目名称:Simulizer,代码行数:12,代码来源:Editor.java

示例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);
      }
    }
  }
}
 
开发者ID:Adrodoc55,项目名称:MPL,代码行数:30,代码来源:MplIdeController.java

示例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);
        }
    }
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:38,代码来源:ClipboardActions.java


注:本文中的javafx.scene.input.Clipboard.getContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。