本文整理匯總了Java中javafx.scene.input.ClipboardContent.putString方法的典型用法代碼示例。如果您正苦於以下問題:Java ClipboardContent.putString方法的具體用法?Java ClipboardContent.putString怎麽用?Java ClipboardContent.putString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.input.ClipboardContent
的用法示例。
在下文中一共展示了ClipboardContent.putString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
});
}
示例2: 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();
}
}
示例3: onCmdCopyEntryAttributes
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
@SuppressWarnings("unused")
@FXML
void onCmdCopyEntryAttributes(ActionEvent evt) {
TreeItem<AttributeModel> rootItem = this.ctlDetailsView.getRoot();
if (rootItem != null) {
StringWriter buffer = new StringWriter();
PrintWriter writer = new PrintWriter(buffer);
for (TreeItem<AttributeModel> attributeItem : rootItem.getChildren()) {
copyEntryAttributesHelper(writer, attributeItem, "");
}
writer.flush();
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(buffer.toString());
clipboard.setContent(content);
}
}
示例4: 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();
}
示例5: 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);
}
}
}
示例6: copy2clipboard
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
private void copy2clipboard(TableView source) {
StringBuilder out = new StringBuilder();
ObservableList<Integer> selectedCells = source.getSelectionModel().getSelectedIndices();
int columns = source.getColumns().size();
for (Integer row : selectedCells) {
for (int idx = 0; idx < columns; idx++) {
TableColumn tc = (TableColumn) source.getColumns().get(idx);
Object item = tc.getCellData((int) row);
out.append(item.toString());
if (idx != columns - 1) {
out.append('\t');
}
}
out.append("\n");
}
ClipboardContent clipboardContent = new ClipboardContent();
clipboardContent.putString(out.toString());
Clipboard.getSystemClipboard().setContent(clipboardContent);
}
示例7: handleCopySpectra
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
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());
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);
}
示例8: copyToClipboard
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
/** Copy currently selected widgets to clipboard
* @return Widgets that were copied or <code>null</code>
*/
public List<Widget> copyToClipboard()
{
if (selection_tracker.isInlineEditorActive())
return null;
final List<Widget> widgets = selection.getSelection();
if (widgets.isEmpty())
return null;
final String xml;
try
{
xml = ModelWriter.getXML(widgets);
}
catch (Exception ex)
{
logger.log(Level.WARNING, "Cannot create content for clipboard", ex);
return null;
}
final ClipboardContent content = new ClipboardContent();
content.putString(xml);
Clipboard.getSystemClipboard().setContent(content);
return widgets;
}
示例9: handle
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
/**
* @see javafx.event.EventHandler#handle(javafx.event.Event)
*/
@Override
public void handle(MouseEvent event)
{
/* drag was detected, start a drag-and-drop gesture */
/* allow any transfer mode */
if (node_ != null)
{
Dragboard db = node_.startDragAndDrop(TransferMode.COPY);
/* Put a string on a dragboard */
String drag = idProvider_.getConceptId();
if (drag != null && drag.length() > 0)
{
ClipboardContent content = new ClipboardContent();
content.putString(drag);
db.setContent(content);
AppContext.getService(DragRegistry.class).conceptDragStarted();
event.consume();
}
}
}
示例10: copy
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
/**
* Transfers the currently selected text to the clipboard,
* leaving the current selection.
*/
default void copy() {
IndexRange selection = getSelection();
if(selection.getLength() > 0) {
ClipboardContent content = new ClipboardContent();
content.putString(getSelectedText());
getStyleCodecs().ifPresent(codecs -> {
Codec<StyledDocument<PS, SEG, S>> codec = ReadOnlyStyledDocument.codec(codecs._1, codecs._2, getSegOps());
DataFormat format = dataFormat(codec.getName());
StyledDocument<PS, SEG, S> doc = subDocument(selection.getStart(), selection.getEnd());
ByteArrayOutputStream os = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(os);
try {
codec.encode(dos, doc);
content.put(format, os.toByteArray());
} catch (IOException e) {
System.err.println("Codec error: Exception in encoding '" + codec.getName() + "':");
e.printStackTrace();
}
});
Clipboard.getSystemClipboard().setContent(content);
}
}
示例11: copyAddress
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
@FXML
public void copyAddress(ActionEvent event) {
try {
ClipboardContent content = new ClipboardContent();
content.putString(getAddress());
Clipboard.getSystemClipboard().setContent(content);
} catch (Exception e) {
e.printStackTrace();
}
}
示例12: copyButtonAction
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
@FXML
private void copyButtonAction(ActionEvent event) {
String fullText = makeStringFromTextFlow();
final Clipboard clipboard = Clipboard.getSystemClipboard();
final ClipboardContent content = new ClipboardContent();
content.putString(fullText);
clipboard.setContent(content);
}
示例13: dragStart
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
private void dragStart (MouseEvent event) {
Dragboard db = startDragAndDrop(TransferMode.MOVE);
ClipboardContent cc = new ClipboardContent();
db.setDragView(myFactory.getTransferImage(this), 0, 0);
cc.putString(serialize(getItem(), getListView().getItems().indexOf(getItem())));
db.setContent(cc);
event.consume();
}
示例14: dragStart
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
private void dragStart () {
Dragboard db = startDragAndDrop(TransferMode.COPY);
ClipboardContent cc = new ClipboardContent();
cc.putString(HOLDER);
db.setContent(cc);
db.setDragView(getDragImage());
myTarget.draw().setOnDragOver(event -> dragOver(event));
myTarget.draw().setOnDragDropped(event -> drop(event));
}
示例15: copyAddress
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
@FXML
protected void copyAddress(ActionEvent event) {
// User clicked icon or menu item.
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(addressStr.get());
content.putHtml(String.format("<a href='%s'>%s</a>", uri(), addressStr.get()));
clipboard.setContent(content);
}