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


Java ClipboardContent類代碼示例

本文整理匯總了Java中javafx.scene.input.ClipboardContent的典型用法代碼示例。如果您正苦於以下問題:Java ClipboardContent類的具體用法?Java ClipboardContent怎麽用?Java ClipboardContent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClipboardContent類屬於javafx.scene.input包,在下文中一共展示了ClipboardContent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setOnDragDetected

import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
/**
 * When the dragging is detected, we place the content of the LabelCell
 * in the DragBoard.
 */
void setOnDragDetected() {
    setOnDragDetected(event -> {

        boolean isParentTask = getTreeItem().getParent().equals(root);

        boolean isEmpty = getTreeItem().getValue().getText().equals("");

        if (!isEmpty && isParentTask) {
            Dragboard db = startDragAndDrop(TransferMode.MOVE);
            ClipboardContent content = new ClipboardContent();
            content.put(controller.DATA_FORMAT, getTreeItem()
                    .getValue());
            db.setContent(content);
        }
        event.consume();
    });
}
 
開發者ID:deltadak,項目名稱:plep,代碼行數:22,代碼來源:CustomTreeCell.java

示例2: initialize

import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
@FXML
private void initialize() throws IOException {
  root.getChildren().addListener((ListChangeListener<? super Node>) change -> {
    while (change.next()) {
      for (Node node : change.getAddedSubList()) {
        if (node instanceof WidgetGallery.WidgetGalleryItem) {
          WidgetGallery.WidgetGalleryItem galleryItem = (WidgetGallery.WidgetGalleryItem) node;
          galleryItem.setOnDragDetected(event -> {
            Dragboard dragboard = galleryItem.startDragAndDrop(TransferMode.COPY);

            // TODO type safety
            ClipboardContent clipboard = new ClipboardContent();
            clipboard.put(DataFormats.widgetType, galleryItem.getWidget().getName());
            dragboard.setContent(clipboard);
            event.consume();
          });
        }
      }
    }
  });
}
 
開發者ID:wpilibsuite,項目名稱:shuffleboard,代碼行數:22,代碼來源:WidgetGalleryController.java

示例3: makeLetterDraggable

import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
/**
 * Adds to the letter the possibility to be dragged on another element.
 *
 * @param letterElement The element to be dragged
 * @param letter        The corresponding letter object
 */
public static void makeLetterDraggable(Node letterElement, LetterInterface letter) {
    // When an user starts to drag a letter
    letterElement.setOnDragDetected(event -> {
        Dragboard dragboard = letterElement.startDragAndDrop(TransferMode.ANY);
        dragboard.setDragView(letterElement.snapshot(null, null));
        letterElement.setVisible(false);

        ClipboardContent clipboardContent = new ClipboardContent();
        clipboardContent.put(LetterInterface.DATA_FORMAT, letter);

        dragboard.setContent(clipboardContent);

        event.consume();
    });

    // When the user has dropped the letter
    letterElement.setOnDragDone(event -> letterElement.setVisible(true));
}
 
開發者ID:Chrisp1tv,項目名稱:ScrabbleGame,代碼行數:25,代碼來源:DraggableLetterManager.java

示例4: call

import javafx.scene.input.ClipboardContent; //導入依賴的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

示例5: setMenuItemDefaultActions

import javafx.scene.input.ClipboardContent; //導入依賴的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

示例6: execute

import javafx.scene.input.ClipboardContent; //導入依賴的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

示例7: execute

import javafx.scene.input.ClipboardContent; //導入依賴的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

示例8: initializeSetOnDragDetected

import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
private void initializeSetOnDragDetected() {
//        LoggerFacade.INSTANCE.debug(this.getClass(), "Initialize setOnDragDetected"); // NOI18N
        
        super.setOnDragDetected(event -> {
            if (super.getItem() == null) {
                return;
            }

            final Dragboard dragboard = startDragAndDrop(TransferMode.MOVE);
            final ClipboardContent content = new ClipboardContent();
            content.putString(String.valueOf(super.getItem().getProjectId()));
//            dragboard.setDragView(
//                    birdImages.get(
//                            items.indexOf(
//                                    getItem()
//                            )
//                    )
//            );
            dragboard.setContent(content);
            event.consume();
        });
    }
 
開發者ID:Naoghuman,項目名稱:Incubator,代碼行數:23,代碼來源:ProjectItemCell.java

示例9: treeProjectFileOnDragDetected

import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
/**
 * 트리 드래그 디텍트 이벤트 처리. <br/>
 * 트리내에 구성된 파일의 위치정보를 드래그 드롭 기능으로 <br/>
 * 전달해주는 역할을 수행한다.<br/>
 * <br/>
 * 
 * @작성자 : KYJ
 * @작성일 : 2017. 11. 21.
 * @param ev
 */
public void treeProjectFileOnDragDetected(MouseEvent ev) {
	TreeItem<JavaProjectFileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
	if (selectedItem == null || selectedItem.getValue() == null) {
		return;
	}

	File file = selectedItem.getValue().getFile();
	if (file == null || !file.exists())
		return;

	Dragboard board = treeProjectFile.startDragAndDrop(TransferMode.LINK);
	ClipboardContent content = new ClipboardContent();
	content.putFiles(Arrays.asList(file));
	board.setContent(content);

	ev.consume();
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:28,代碼來源:SystemLayoutViewController.java

示例10: keyOnPressd

import javafx.scene.input.ClipboardContent; //導入依賴的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

示例11: CodeAreaClipboardItemListView

import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
public CodeAreaClipboardItemListView() {

		// List<ClipboardContent> clipBoardItems = parent.getClipBoardItems();
		setCellFactory(TextFieldListCell.forListView(new StringConverter<ClipboardContent>() {

			@Override
			public String toString(ClipboardContent object) {
				return object.getString();
			}

			@Override
			public ClipboardContent fromString(String string) {
				return null;
			}
		}));
		setOnKeyPressed(this::onKeyPress);
		setOnMouseClicked(this::onMouseClick);
	}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:19,代碼來源:CodeAreaClipboardItemListView.java

示例12: onKeyPress

import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
void onKeyPress(KeyEvent e) {
	if (e.getCode() == KeyCode.ESCAPE) {
		if (e.isConsumed())
			return;

		if (this.window != null) {
			this.window.hide();
		}

		e.consume();
	} else if (e.getCode() == KeyCode.ENTER) {
		if (e.isConsumed())
			return;

		ClipboardContent selectedItem = getSelectionModel().getSelectedItem();
		if (selectItemAction(selectedItem))
			this.window.hide();
		e.consume();
	}
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:21,代碼來源:CodeAreaClipboardItemListView.java

示例13: cutSelectionToClipboard

import javafx.scene.input.ClipboardContent; //導入依賴的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

示例14: handle

import javafx.scene.input.ClipboardContent; //導入依賴的package包/類
@Override
public void handle(final MouseEvent event) {
    final Pane pane = (Pane) event.getSource();
    final ImageView view = (ImageView) pane.getChildren().get(0);
    final Dragboard db = view.startDragAndDrop(TransferMode.COPY);
    final ClipboardContent content = new ClipboardContent();
    content.putString(view.getId());
    final ComponentPane componentPane = loadComponent(pane.getChildren().get(0).getId().toLowerCase());
    workspace.getChildren().add(componentPane);
    componentPane.applyCss();
    final WritableImage w  = componentPane.snapshot(null,null);
    workspace.getChildren().remove(componentPane);
    content.putImage(w);
    db.setContent(content);
    event.consume();
}
 
開發者ID:StephaneMangin,項目名稱:Synth,代碼行數:17,代碼來源:CoreController.java

示例15: copyValue

import javafx.scene.input.ClipboardContent; //導入依賴的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


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