Example usage for javafx.scene.input Clipboard getSystemClipboard

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

Introduction

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

Prototype

public static Clipboard getSystemClipboard() 

Source Link

Document

Gets the current system clipboard, through which data can be stored and retrieved.

Usage

From source file:Main.java

public static void main(String[] args) {
    DataFormat fmt = new DataFormat("text/foo", "text/bar");
    Clipboard clipboard = Clipboard.getSystemClipboard();
    ClipboardContent content = new ClipboardContent();
    content.put(fmt, "Hello");
    clipboard.setContent(content);/*from   w ww .ja v a 2  s .  c  o  m*/
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");
    Group root = new Group();
    Scene scene = new Scene(root, 550, 250, Color.web("0x0000FF"));

    final Clipboard clipboard = Clipboard.getSystemClipboard();
    final ClipboardContent content = new ClipboardContent();
    content.putString("some text");
    content.put(DataFormat.PLAIN_TEXT, "other text");
    clipboard.setContent(content);/*from   w w  w  . ja  va2  s . c o m*/

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:com.bekwam.mavenpomupdater.ToolBarDelegate.java

public void init() {
    if (log.isDebugEnabled()) {
        log.debug("[INIT]");
    }/*from w ww  . jav  a  2 s.  co  m*/

    if (systemClipboard == null) {
        systemClipboard = Clipboard.getSystemClipboard();
    }

    if (systemClipboard.hasContent(DataFormat.PLAIN_TEXT)) {
        tbPaste.setDisable(false);
    }

}

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  a v a 2 s. com
        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  .  ja va  2s  .co  m
            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);/*  w  w w .j  a  va 2  s . c om*/
    clipboard.setContent(content);
}

From source file:org.pdfsam.ui.log.LogPaneTest.java

@Test
public void copy() throws Exception {
    FXTestUtils.invokeAndWait(() -> {
        Clipboard.getSystemClipboard().clear();
        assertTrue(isBlank(Clipboard.getSystemClipboard().getString()));
    }, 2);//from   w w w  . j  a v a  2s.co m
    click("A message").rightClick("A message").click("#copyLogMenuItem");
    FXTestUtils.invokeAndWait(
            () -> assertTrue(Clipboard.getSystemClipboard().getString().contains("A message")), 1);
}

From source file:org.pdfsam.ui.dashboard.about.AboutDashboardPane.java

@Inject
public AboutDashboardPane(Pdfsam pdfsam) {
    getStyleClass().add("dashboard-container");
    VBox left = new VBox(5);
    addSectionTitle(pdfsam.name(), left);
    Label copyright = new Label("Copyright 2014 by Andrea Vacondio");
    AwesomeDude.setIcon(copyright, AwesomeIcon.COPYRIGHT);
    left.getChildren().addAll(new Label(String.format("ver. %s", pdfsam.version())), copyright);
    addHyperlink(null, "http://www.gnu.org/licenses/agpl-3.0.html", "GNU Affero General Public License v3",
            left);/*  w  ww.  jav a  2  s  .co  m*/
    addHyperlink(AwesomeIcon.HOME, "http://www.pdfsam.org", "www.pdfsam.org", left);
    addHyperlink(AwesomeIcon.RSS_SQUARE, "http://www.pdfsam.org/feed/",
            DefaultI18nContext.getInstance().i18n("Subscribe to the official news feed"), left);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Environment"), left);
    Label runtime = new Label(String.format("%s %s", System.getProperty("java.runtime.name"),
            System.getProperty("java.runtime.version")));
    Label fxRuntime = new Label(
            String.format("JavaFX %s", com.sun.javafx.runtime.VersionInfo.getRuntimeVersion()));
    Label memory = new Label(DefaultI18nContext.getInstance().i18n("Max memory {0}",
            FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory())));
    Button copyButton = new Button(DefaultI18nContext.getInstance().i18n("Copy to clipboard"));
    AwesomeDude.setIcon(copyButton, AwesomeIcon.COPY);
    copyButton.getStyleClass().addAll(Style.BUTTON.css());
    copyButton.setId("copyEnvDetails");
    copyButton.setOnAction(a -> {
        ClipboardContent content = new ClipboardContent();
        writeContent(Arrays.asList(pdfsam.name(), pdfsam.version(), runtime.getText(), fxRuntime.getText(),
                memory.getText())).to(content);
        Clipboard.getSystemClipboard().setContent(content);
    });
    left.getChildren().addAll(runtime, fxRuntime, memory, copyButton);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Thanks to"), left);
    addHyperlink(null, "http://www.pdfsam.org/thanks_to",
            DefaultI18nContext.getInstance().i18n("The open source projects making PDFsam possible"), left);
    VBox right = new VBox(5);
    addSectionTitle(DefaultI18nContext.getInstance().i18n("Support"), right);
    addHyperlink(AwesomeIcon.BUG, "http://www.pdfsam.org/issue_tracker",
            DefaultI18nContext.getInstance().i18n("Bug and feature requests"), right);
    addHyperlink(AwesomeIcon.QUESTION_CIRCLE, "http://www.pdfsam.org/wiki", "HowTo wiki", right);
    addHyperlink(AwesomeIcon.YOUTUBE_PLAY, "http://www.pdfsam.org/quickstart_video",
            DefaultI18nContext.getInstance().i18n("Play the \"get started\" video"), right);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Contribute"), right);
    addHyperlink(AwesomeIcon.GITHUB, "http://www.pdfsam.org/scm",
            DefaultI18nContext.getInstance().i18n("Fork PDFsam on GitHub"), right);
    addHyperlink(AwesomeIcon.FLAG_ALT, "http://www.pdfsam.org/translate",
            DefaultI18nContext.getInstance().i18n("Translate"), right);
    addHyperlink(AwesomeIcon.DOLLAR, "http://www.pdfsam.org/donate",
            DefaultI18nContext.getInstance().i18n("Donate"), right);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Social"), right);
    addHyperlink(AwesomeIcon.TWITTER_SQUARE, "http://www.pdfsam.org/twitter",
            DefaultI18nContext.getInstance().i18n("Follow us on Twitter"), right);
    addHyperlink(AwesomeIcon.GOOGLE_PLUS_SQUARE, "http://www.pdfsam.org/gplus",
            DefaultI18nContext.getInstance().i18n("Follow us on Google Plus"), right);
    addHyperlink(AwesomeIcon.FACEBOOK_SQUARE, "http://www.pdfsam.org/facebook",
            DefaultI18nContext.getInstance().i18n("Like us on Facebook"), right);
    getChildren().addAll(left, right);

}

From source file:io.github.mzmine.util.jfreechart.JFreeChartUtils.java

public static void exportToClipboard(ChartViewer chartNode) {
    final Clipboard clipboard = Clipboard.getSystemClipboard();
    final ClipboardContent content = new ClipboardContent();
    final int width = (int) chartNode.getWidth();
    final int height = (int) chartNode.getHeight();
    WritableImage img = new WritableImage(width, height);
    SnapshotParameters params = new SnapshotParameters();
    chartNode.snapshot(params, img);/*from w  ww . j a  v  a2  s . co  m*/
    content.putImage(img);
    clipboard.setContent(content);
}

From source file:com.bekwam.mavenpomupdater.ToolBarDelegate.java

public void updateToolBarForClipboard(TextField focusedTF, String selectedText, IndexRange selectedRange) {

    if (log.isDebugEnabled()) {
        log.debug("[UPDATE TBB]");
    }//from  www  .  j ava  2s  .  com

    if (systemClipboard == null) {
        systemClipboard = Clipboard.getSystemClipboard();
    }

    if (systemClipboard.hasString()) {
        if (log.isDebugEnabled()) {
            log.debug("[UPDATE TBB] there is content in clipboard");
        }
        adjustForClipboardContents();
    } else {
        if (log.isDebugEnabled()) {
            log.debug("[UPDATE TBB] there is NO content in clipboard");
        }
        adjustForEmptyClipboard();
    }

    if (StringUtils.isNotEmpty(focusedTF.getSelectedText())) {
        if (log.isDebugEnabled()) {
            log.debug("[UPDATE TBB] there is a selection");
        }
        adjustForSelection();

    } else {
        if (log.isDebugEnabled()) {
            log.debug("[UPDATE TBB] there is a de-selection");
        }
        adjustForDeselection();
    }

    if (log.isDebugEnabled()) {
        log.debug(
                "[UPDATE TBB]  assigining tf=" + focusedTF.getId() + " as last focused; text=" + selectedText);
    }

    lastFocusedTF = focusedTF;
    lastSelectedText = selectedText;
    lastSelectedRange = selectedRange;
}