當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。