Example usage for javafx.scene.input Clipboard setContent

List of usage examples for javafx.scene.input Clipboard setContent

Introduction

In this page you can find the example usage for javafx.scene.input Clipboard setContent.

Prototype


public final boolean setContent(Map<DataFormat, Object> content) 

Source Link

Document

Puts content onto the clipboard.

Usage

From source file:com.chart.SwingChart.java

/**
 * Copy to clipboard/*from  w ww  .j  av a  2 s . co m*/
 * @param node JavaFX Node to copy
 */
public final void copyClipboard(final Node node) {

    WritableImage captura = node.snapshot(new SnapshotParameters(), null);

    ImageView iv = new ImageView(captura);

    Clipboard clipboard = Clipboard.getSystemClipboard();
    ClipboardContent content = new ClipboardContent();
    content.put(DataFormat.IMAGE, captura);
    clipboard.setContent(content);

}

From source file:net.rptools.tokentool.controller.TokenTool_Controller.java

@FXML
void editCopyImageMenu_onAction(ActionEvent event) {
    Clipboard clipboard = Clipboard.getSystemClipboard();
    ClipboardContent content = new ClipboardContent();

    // for paste as file, e.g. in Windows Explorer
    try {//from   w w  w  .  j a v a  2  s .c  o  m
        File tempTokenFile = fileSaveUtil.getTempFileName(false, useFileNumberingCheckbox.isSelected(),
                fileNameTextField.getText(), fileNameSuffixTextField);

        writeTokenImage(tempTokenFile);
        content.putFiles(java.util.Collections.singletonList(tempTokenFile));
        tempTokenFile.deleteOnExit();
    } catch (Exception e) {
        log.error(e);
    }

    // for paste as image, e.g. in GIMP
    content.putImage(tokenImageView.getImage());

    // Finally, put contents on clip board
    clipboard.setContent(content);
}

From source file:ubicrypt.ui.ctrl.ExportConfigCtrl.java

@Override
public void initialize(final URL location, final ResourceBundle resources) {
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final ArmoredOutputStream armor = new ArmoredOutputStream(out);
    try {/*from  w w  w  . j  av  a2s . c  om*/
        armor.write(IOUtils.toByteArray(pgpService
                .encrypt(Utils.marshallIs(ExportConfig.copyFrom(localConfig, keyPair.getPublicKey())))));
        armor.close();
    } catch (final IOException e) {
        log.error(e.getMessage(), e);
    }
    text.setText(out.toString());
    copy.setOnMouseClicked(event -> {
        final Clipboard clipboard = Clipboard.getSystemClipboard();
        final ClipboardContent content = new ClipboardContent();
        content.putString(out.toString());
        clipboard.setContent(content);
    });
    cancel.setOnMouseClicked(event -> navigator.popLayer());
}

From source file:ubicrypt.ui.ctrl.SettingsController.java

@Override
public void initialize(final URL location, final ResourceBundle resources) {
    String fxml = substringBefore(substringAfterLast(location.getFile(), "/"), ".fxml");
    StackNavigator navigator = new StackNavigator(main, fxml, controllerFactory);

    copyPKClipboard.setOnMouseClicked(event -> {
        try {//from   ww w. j  a  va2 s .c  om
            final ByteArrayOutputStream out = new ByteArrayOutputStream();
            final ArmoredOutputStream armor = new ArmoredOutputStream(out);
            armor.write(PGPEC.signPK(keyPair.getPublicKey(), signKey).getEncoded());
            armor.close();
            final Clipboard clipboard = Clipboard.getSystemClipboard();
            final ClipboardContent content = new ClipboardContent();
            content.putString(new String(out.toByteArray()));
            clipboard.setContent(content);
            //                anchor.getChildren().add(notification);
            final NotificationPane notification = new NotificationPane(main);
            notification.setText("Public Key copied in clipboard");
            notification.show();
            log.info("public key copied into clipboard");
        } catch (final IOException e) {
            Throwables.propagate(e);
        }
    });

    addNewPK.setOnMouseClicked(event -> navigator.browse("addNewPK"));
    importConfig.setOnMouseClicked(event -> navigator.browse("importConfig"));
    exportConfig.setOnMouseClicked(event -> navigator.browse("exportConfig"));
}

From source file:wo.trade.Util.java

public static void copyToClipboard(String str) {
    Clipboard clipboard = Clipboard.getSystemClipboard();
    final ClipboardContent content = new ClipboardContent();
    content.putString(str);//from w ww  .j a  va 2  s . c  om
    clipboard.setContent(content);
}