List of usage examples for javafx.scene.input Clipboard setContent
public final boolean setContent(Map<DataFormat, Object> content)
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 source file:io.bitsquare.common.util.Utilities.java
public static void copyToClipboard(String content) { try {/*from w ww . j a v a 2 s . c o m*/ if (content != null && content.length() > 0) { Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent clipboardContent = new ClipboardContent(); clipboardContent.putString(content); clipboard.setContent(clipboardContent); } } catch (Throwable e) { log.error("copyToClipboard failed " + e.getMessage()); e.printStackTrace(); } }
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);/* ww w . j av a 2 s .c o m*/ content.putImage(img); clipboard.setContent(content); }
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); primaryStage.setScene(scene);//from w w w. j ava 2 s . co m primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { stage.setTitle("Menu Sample"); Scene scene = new Scene(new VBox(), 400, 350); scene.setFill(Color.OLDLACE); name.setFont(new Font("Verdana Bold", 22)); binName.setFont(new Font("Arial Italic", 10)); pic.setFitHeight(150);//from w ww. j av a 2s . c om pic.setPreserveRatio(true); description.setWrapText(true); description.setTextAlignment(TextAlignment.JUSTIFY); shuffle(); MenuBar menuBar = new MenuBar(); // --- Graphical elements final VBox vbox = new VBox(); vbox.setAlignment(Pos.CENTER); vbox.setSpacing(10); vbox.setPadding(new Insets(0, 10, 0, 10)); vbox.getChildren().addAll(name, binName, pic, description); // --- Menu File Menu menuFile = new Menu("File"); MenuItem add = new MenuItem("Shuffle", new ImageView(new Image("src/menusample/new.png"))); add.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { shuffle(); vbox.setVisible(true); } }); MenuItem clear = new MenuItem("Clear"); clear.setAccelerator(KeyCombination.keyCombination("Ctrl+X")); clear.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { vbox.setVisible(false); } }); MenuItem exit = new MenuItem("Exit"); exit.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { System.exit(0); } }); menuFile.getItems().addAll(add, clear, new SeparatorMenuItem(), exit); // --- Menu Edit Menu menuEdit = new Menu("Edit"); Menu menuEffect = new Menu("Picture Effect"); final ToggleGroup groupEffect = new ToggleGroup(); for (Entry effect : effects) { RadioMenuItem itemEffect = new RadioMenuItem((String) effect.getKey()); itemEffect.setUserData(effect.getValue()); itemEffect.setToggleGroup(groupEffect); menuEffect.getItems().add(itemEffect); } final MenuItem noEffects = new MenuItem("No Effects"); noEffects.setDisable(true); noEffects.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { pic.setEffect(null); groupEffect.getSelectedToggle().setSelected(false); noEffects.setDisable(true); } }); groupEffect.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { public void changed(ObservableValue ov, Toggle old_toggle, Toggle new_toggle) { if (groupEffect.getSelectedToggle() != null) { Effect effect = (Effect) groupEffect.getSelectedToggle().getUserData(); pic.setEffect(effect); noEffects.setDisable(false); } else { noEffects.setDisable(true); } } }); menuEdit.getItems().addAll(menuEffect, noEffects); // --- Menu View Menu menuView = new Menu("View"); CheckMenuItem titleView = createMenuItem("Title", name); CheckMenuItem binNameView = createMenuItem("Binomial name", binName); CheckMenuItem picView = createMenuItem("Picture", pic); CheckMenuItem descriptionView = createMenuItem("Decsription", description); menuView.getItems().addAll(titleView, binNameView, picView, descriptionView); menuBar.getMenus().addAll(menuFile, menuEdit, menuView); // --- Context Menu final ContextMenu cm = new ContextMenu(); MenuItem cmItem1 = new MenuItem("Copy Image"); cmItem1.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); content.putImage(pic.getImage()); clipboard.setContent(content); } }); cm.getItems().add(cmItem1); pic.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (e.getButton() == MouseButton.SECONDARY) cm.show(pic, e.getScreenX(), e.getScreenY()); } }); ((VBox) scene.getRoot()).getChildren().addAll(menuBar, vbox); stage.setScene(scene); stage.show(); }
From source file:com.ggvaidya.scinames.complexquery.ComplexQueryViewController.java
@FXML private void copyToClipboard(ActionEvent evt) { try {/* w w w.j av a 2 s . c o m*/ StringWriter writer = new StringWriter(); List<List<String>> dataAsTable = getDataAsTable(); fillCSVFormat(CSVFormat.TDF, writer, getDataAsTable()); Clipboard clipboard = Clipboard.getSystemClipboard(); HashMap<DataFormat, Object> content = new HashMap<>(); content.put(DataFormat.PLAIN_TEXT, writer.getBuffer().toString()); clipboard.setContent(content); Alert window = new Alert(Alert.AlertType.CONFIRMATION, (dataAsTable.get(0).size() - 1) + " rows written to clipboard."); window.showAndWait(); } catch (IOException e) { Alert window = new Alert(Alert.AlertType.ERROR, "Could not save CSV to the clipboard: " + e); window.showAndWait(); } }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void tblTerms_OnKeyPressed(KeyEvent keyEvent) { if (keyEvent.isControlDown()) { // LOG.debug("keyEvent.getCharacter(): " + keyEvent.getCharacter()); // LOG.debug("keyEvent.getCode().getName(): " + keyEvent.getCode().getName()); if (keyEvent.getCode().getName().equals("C")) { final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); Term term = tblTerms.getSelectionModel().getSelectedItem(); content.putString(term.getText()); clipboard.setContent(content); }/* ww w .ja v a 2s .c o m*/ } else if (keyEvent.getCode().getName().equalsIgnoreCase("M")) { this.markTerm(); } else if (keyEvent.getCode().getName().equalsIgnoreCase("E")) { this.doExpansions(); } else if (keyEvent.getCode().getName().equalsIgnoreCase("B")) { this.doBack(); } else if (keyEvent.getCode().getName().equalsIgnoreCase("F")) { this.doForward(); } }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void tblContexts_OnKeyPressed(KeyEvent keyEvent) { if (keyEvent.isControlDown()) { if (keyEvent.getCode().getName().equals("C")) { final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); Context context = tblContexts.getSelectionModel().getSelectedItem(); content.putString(context.getTextSegment()); clipboard.setContent(content); }// w w w. j a v a2 s . c o m } }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleCopySplash(Event event) { StringBuilder sb = new StringBuilder(); for (MsSpectrumDataSet dataset : datasets) { MsSpectrum spectrum = dataset.getSpectrum(); String splash = SplashCalculationAlgorithm.calculateSplash(spectrum); sb.append(dataset.getName());/*from w w w . j a va 2 s . c om*/ sb.append(" SPLASH ID: "); sb.append(splash); sb.append("\n"); } final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); content.putString(sb.toString()); clipboard.setContent(content); }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleCopySpectra(Event event) { StringBuilder sb = new StringBuilder(); for (MsSpectrumDataSet dataset : datasets) { MsSpectrum spectrum = dataset.getSpectrum(); String spectrumString = TxtExportAlgorithm.spectrumToString(spectrum); String splash = SplashCalculationAlgorithm.calculateSplash(spectrum); sb.append("# "); sb.append(dataset.getName());//from w w w .j a va2 s . co m sb.append("\n"); sb.append("# SPLASH ID: "); sb.append(splash); sb.append("\n"); sb.append(spectrumString); sb.append("\n"); } final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); content.putString(sb.toString()); clipboard.setContent(content); }