Java Code Examples for javafx.scene.image.ImageView#setOnDragDetected()

The following examples show how to use javafx.scene.image.ImageView#setOnDragDetected() . 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: SuitStack.java    From Solitaire with GNU General Public License v2.0 7 votes vote down vote up
SuitStack(FoundationPile pIndex)
{
	aIndex = pIndex;
	setPadding(new Insets(PADDING));
	setStyle(BORDER_STYLE);
	final ImageView image = new ImageView(CardImages.getBack());
   	image.setVisible(false);
      	getChildren().add(image);
   	aDragHandler = new CardDragHandler(image);
   	image.setOnDragDetected(aDragHandler);
   	setOnDragOver(createOnDragOverHandler(image));
   	setOnDragEntered(createOnDragEnteredHandler());
   	setOnDragExited(createOnDragExitedHandler());
   	setOnDragDropped(createOnDragDroppedHandler());
   	GameModel.instance().addListener(this);
}
 
Example 2
Source File: DragDrop.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets up the image view as the source
 * @param source
 */
private void setupGestureSource(final ImageView source){

    source.setOnDragDetected(new EventHandler <MouseEvent>() {
       @Override
       public void handle(MouseEvent event) {

           /* allow any transfer mode */
           Dragboard db = source.startDragAndDrop(TransferMode.COPY);

           /* put a image on dragboard */
           ClipboardContent content = new ClipboardContent();

           Image sourceImage = source.getImage();
           content.putImage(sourceImage);
           db.setContent(content);

           event.consume();
       }
   });

}
 
Example 3
Source File: DiscardPileView.java    From Solitaire with GNU General Public License v2.0 5 votes vote down vote up
DiscardPileView()
{
	setPadding(new Insets(PADDING));
   	final ImageView image = new ImageView(CardImages.getBack());
   	image.setVisible(false);
      	getChildren().add(image);
   	aDragHandler = new CardDragHandler(image);
   	image.setOnDragDetected(aDragHandler);
   	GameModel.instance().addListener(this);
}