List of usage examples for javafx.scene.input DataFormat PLAIN_TEXT
DataFormat PLAIN_TEXT
To view the source code for javafx.scene.input DataFormat PLAIN_TEXT.
Click Source Link
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 .j a v a 2 s .com primaryStage.setScene(scene); primaryStage.show(); }
From source file:com.bekwam.mavenpomupdater.ToolBarDelegate.java
public void init() { if (log.isDebugEnabled()) { log.debug("[INIT]"); }/*from ww w.j a va 2s . co m*/ if (systemClipboard == null) { systemClipboard = Clipboard.getSystemClipboard(); } if (systemClipboard.hasContent(DataFormat.PLAIN_TEXT)) { tbPaste.setDisable(false); } }
From source file:com.bekwam.mavenpomupdater.ToolBarDelegate.java
public void paste() { if (log.isDebugEnabled()) { log.debug("[PASTE]"); }/*from w w w. ja v a2 s.co m*/ if (!systemClipboard.hasContent(DataFormat.PLAIN_TEXT)) { adjustForEmptyClipboard(); return; } String clipboardText = systemClipboard.getString(); if (log.isDebugEnabled()) { log.debug("[PASTE] pasting clipboard text=" + clipboardText); } if (log.isDebugEnabled()) { log.debug( "[PASTE] range start=" + lastSelectedRange.getStart() + ", end=" + lastSelectedRange.getEnd()); } int endPos = 0; if (lastSelectedRange.getStart() == lastSelectedRange.getEnd()) { endPos = lastSelectedRange.getEnd() + StringUtils.length(clipboardText); } else { endPos = lastSelectedRange.getStart() + StringUtils.length(clipboardText); } lastFocusedTF.replaceText(lastSelectedRange, clipboardText); lastFocusedTF.requestFocus(); lastFocusedTF.positionCaret(endPos); }
From source file:com.bekwam.mavenpomupdater.MenuBarDelegate.java
public void paste() { if (log.isDebugEnabled()) { log.debug("[PASTE]"); }/* w w w.j a va2 s . c o m*/ if (!systemClipboard.hasContent(DataFormat.PLAIN_TEXT)) { adjustForEmptyClipboard(); return; } TextField focusedTF = getFocusedTextField(); focusedTF.paste(); }
From source file:bear.main.FXConf.java
public void copyToClipboard(String text) { HashMap<DataFormat, Object> map = new HashMap<DataFormat, Object>(); map.put(DataFormat.PLAIN_TEXT, text); Clipboard.getSystemClipboard().setContent(map); }
From source file:com.ggvaidya.scinames.complexquery.ComplexQueryViewController.java
@FXML private void copyToClipboard(ActionEvent evt) { try {/*from 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(); } }