Java Code Examples for javafx.scene.input.Dragboard#setContent()

The following examples show how to use javafx.scene.input.Dragboard#setContent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NBTTreeView.java    From mcaselector with MIT License 6 votes vote down vote up
private void onDragDetected(MouseEvent e) {
	if (getTreeItem() == getTreeView().getRoot()) {
		return;
	}
	Dragboard db = startDragAndDrop(TransferMode.MOVE);
	WritableImage wi = new WritableImage((int) getWidth(), (int) getHeight());
	Image dbImg = snapshot(null, wi);
	db.setDragView(dbImg);
	if (USE_DRAGVIEW_OFFSET) {
		db.setDragViewOffsetX(getWidth() / 2);
		db.setDragViewOffsetY(getHeight() / 2);
	}
	ClipboardContent cbc = new ClipboardContent();
	cbc.put(CLIPBOARD_DATAFORMAT, true);
	db.setContent(cbc);
	dragboardContent = getTreeItem();
	e.consume();
}
 
Example 2
Source File: DockItem.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Allow dragging this item */
private void handleDragDetected(final MouseEvent event)
{
    // Disable dragging from a 'fixed' pane
    if (getDockPane().isFixed())
        return;

    final Dragboard db = name_tab.startDragAndDrop(TransferMode.MOVE);

    final ClipboardContent content = new ClipboardContent();
    content.put(DOCK_ITEM, getLabel());
    db.setContent(content);

    final DockItem previous = dragged_item.getAndSet(this);
    if (previous != null)
        logger.log(Level.WARNING, "Already dragging " + previous);

    event.consume();
}
 
Example 3
Source File: SearchBox.java    From mdict-java with GNU General Public License v3.0 5 votes vote down vote up
protected void startDrag(MouseEvent event) {
	TextField textBox = ((TextField)event.getSource());
	if(!"".equals(textBox.getSelectedText()) && textBox.getText().equals(textBox.getSelectedText())) {
        Dragboard db = textBox.startDragAndDrop(TransferMode.MOVE);
        snapshotter.setText(textBox.getText());
        db.setDragView(snapshotter.snapshot(null, null));
        ClipboardContent cc = new ClipboardContent();
        cc.put(DataFormat.PLAIN_TEXT, textBox.getSelectedText());
        db.setContent(cc);
        event.consume();
	}
}
 
Example 4
Source File: CardDragHandler.java    From Solitaire with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void handle(MouseEvent pMouseEvent)
{
	Dragboard db = aImageView.startDragAndDrop(TransferMode.ANY);
       CLIPBOARD_CONTENT.putString(aCard.getIDString());
       db.setContent(CLIPBOARD_CONTENT);
       pMouseEvent.consume();
}
 
Example 5
Source File: CardPileView.java    From Solitaire with GNU General Public License v2.0 5 votes vote down vote up
private EventHandler<MouseEvent> createDragDetectedHandler(final ImageView pImageView, final Card pCard)
{
	return new EventHandler<MouseEvent>() 
	{
		@Override
		public void handle(MouseEvent pMouseEvent) 
		{
			Dragboard db = pImageView.startDragAndDrop(TransferMode.ANY);
			CLIPBOARD_CONTENT.putString(CardTransfer.serialize(GameModel.instance().getSubStack(pCard, aIndex)));
			db.setContent(CLIPBOARD_CONTENT);
			pMouseEvent.consume();
		}
	};
}
 
Example 6
Source File: DeckBuilderWindow.java    From Cardshifter with Apache License 2.0 5 votes vote down vote up
private void startDragToActiveDeck(MouseEvent event, Pane pane, CardInfoMessage message) {
this.cardBeingDragged = message;
	Dragboard db = pane.startDragAndDrop(TransferMode.MOVE);
	ClipboardContent content = new ClipboardContent();
	content.putString(message.toString());
	db.setContent(content);
event.consume();
}