當前位置: 首頁>>代碼示例>>Java>>正文


Java Clipboard類代碼示例

本文整理匯總了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;
}
 
開發者ID:xfangfang,項目名稱:PhotoScript,代碼行數:24,代碼來源:Controller.java

示例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);
		});
	});
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:25,代碼來源:SampServerTable.java

示例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));
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:26,代碼來源:TreeNode.java

示例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);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:17,代碼來源:CopyFileAction.java

示例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();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:23,代碼來源:PasteFileAction.java

示例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);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:18,代碼來源:CutFileAction.java

示例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();
		}

	}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:23,代碼來源:XMLTreeView.java

示例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();
			}
		}
	}
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:34,代碼來源:TinymceDeligator.java

示例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;
}
 
開發者ID:Californius,項目名稱:CSVboard,代碼行數:28,代碼來源:TableKeyEventHandler.java

示例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);
    }
  }
}
 
開發者ID:comtel2000,項目名稱:opc-ua-client,代碼行數:26,代碼來源:DataTreeViewPresenter.java

示例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;
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:26,代碼來源:DragDropWithControls.java

示例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(", ")));
}
 
開發者ID:Maia-Everett,項目名稱:questfiller,代碼行數:19,代碼來源:MainWindow.java

示例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);

}
 
開發者ID:littleyoda,項目名稱:amazon.de-Orders,代碼行數:25,代碼來源:KeyEventHandlerTableview.java

示例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);
		}
	}
}
 
開發者ID:hdecarne,項目名稱:certmgr,代碼行數:19,代碼來源:StoreController.java

示例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);
	}
}
 
開發者ID:hdecarne,項目名稱:certmgr,代碼行數:23,代碼來源:StoreController.java


注:本文中的javafx.scene.input.Clipboard類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。