How to get mouse during a DND operation events

Hi all, I'am trying to introduce Visual cues for when drag - déposer occurs on a node of javafx DND however seems to consume all mouse events. Is it possible to fix this?

I created a simple example of the problem where mouse events stop clearly when an MDN occurs.
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.util.List;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javax.swing.JFrame;

/**
 *
 * @author Dave
 */
public class TestFileDrop{

    private static JFXPanel javafxPanel;
    private static Rectangle lbl_background;
    private static Label num_files_lbl;
    private Scene scene;
    public static void main(String[] args) {
        new TestFileDrop().initAndShowGUI();
    }
    private void initAndShowGUI() {
        TmpFxLauncher.launch();
        JFrame frame = new JFrame("TestFileDrop");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        javafxPanel = new JFXPanel();
        javafxPanel.setPreferredSize(new Dimension(400,400));
        frame.getContentPane().add(javafxPanel);
        Platform.runLater(new Runnable() {
            public void run() {
                createScene();
            }
        });
        frame.pack();
        frame.setVisible(true);
    }
    public static class TmpFxLauncher extends Application {
        @Override public void start(Stage primaryStage) {
        }
        private static void launch() {
            launch(null);
        }
    }
    public void createScene() {
        Group root = new Group();
        scene = new Scene(root);
        
        StackPane sp = new StackPane();  
        sp.setTranslateX(100);
        sp.setTranslateY(100);
        lbl_background= new Rectangle();
        lbl_background.setWidth(200);
        lbl_background.setHeight(200);
        lbl_background.setFill(Color.RED);
        lbl_background.setOnMouseEntered(new EventHandler<MouseEvent>(){
            @Override
            public void handle(MouseEvent me){
                lbl_background.setFill(Color.BLUE);
            }
        });
        lbl_background.setOnMouseExited(new EventHandler<MouseEvent>(){
            @Override
            public void handle(MouseEvent me){
                lbl_background.setFill(Color.RED);
            }
        });
        sp.getChildren().add(lbl_background);
        num_files_lbl = new Label("Awaiting Drop");
        num_files_lbl.setAlignment(Pos.CENTER);
        num_files_lbl.setPrefWidth(150);
        num_files_lbl.setPrefHeight(20);       
        num_files_lbl.setMouseTransparent(true);
        sp.getChildren().add(num_files_lbl);
        root.getChildren().add(sp);
        javafxPanel.setScene(scene);
        enableDragAndDrop();
    }
    private void enableDragAndDrop(){
        Frame [] frames = Frame.getFrames();
        if(frames.length > 0){
            Frame top_frame = frames[0];
            top_frame.setDropTarget(new DropTarget(){
            @Override
            public synchronized void drop(DropTargetDropEvent dtde) {
                try{
                    final DropTargetDropEvent my_drop = dtde;
                    Transferable t = my_drop.getTransferable();
                    System.out.println(t.toString());
                    if (my_drop.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                        my_drop.acceptDrop(my_drop.getDropAction());
                        final List data = (List) t.getTransferData(DataFlavor.javaFileListFlavor);
                        Platform.runLater(new Runnable(){
                            public void run(){
                                num_files_lbl.setText("Files Dropped:"+data.size());                                                       
                            }
                       });   
                       my_drop.dropComplete(true);                
                    }
                    else{
                        dtde.rejectDrop();
                    }
                }
                catch (java.io.IOException e){
                    System.out.println(e.getMessage());
                }
                catch (UnsupportedFlavorException e) {
                    System.out.println(e.getMessage());
                }
            }
            @Override
            public synchronized void dragOver(DropTargetDragEvent dtde) {
               
            }    
            });           
        }
    }  
}
Published by: 867313 on July 24, 2011 10:49

Once again, please read the documentation of the API for DragEvent.

Event DRAG_DETECTED has nothing to do with gout, DND gesture beginning. Your target must let the system know that there is a drop target, and that let you down here "is not invalid. Here are the respective part of the documentation:

In the handler DRAG_OVER a potential target of the fall has the capacity to know that he is a real target. This is done by calling acceptTransferModes(TransferMode...) on the event, passing modes of transfer, that it is willing to accept. If it is not called during the delivery of events, or if none of the modes of transfer spent is supported by the source of the gesture, the potential drop target does not have to be a real drop target.

Tags: Java

Similar Questions

  • How to get the ActiveX component value change event?

    Hi all

    LV 8.6.1

    I try to get the ActiveX component value change event. I covered forum and through examples, but I can't get an idea of how "Recalling vi. For example, in the example 'ActiveX event Callback for IE.vi' it is used "recall vi". I've added an example where the change event of value with the mouse to the bottom of the event are scheduled to the structure of the event. Mouse down event OK work but change the value no. Can anyone describe what I need to add to my example vi who value the change event works fine?

    BR, Jim

    Here is the solution! "Value changed event" is not performed in the structure of the event, but in "Reminder VI".

  • How to get the current location in the event thread?

    Hello!

    Can U pls tell me how to get the location where the thread object, it is in method() execution of MenuItem. PLS, tell me-

    I also used the different thread for the getLocation() method. But I do not have the coords of geo location...

    PLS, suggest me-

    My code is as below:

        private MenuItem getGeoCodes=new MenuItem("Current Coords",100,1){
    
                                 public void run(){
                                     double[] coords=getLocationCoords();
                                     this.wait(12000);
                                     System.out.println("Latitude :"+coords[0]+" "+"Longitude:"+coords[1]);
                                 }
    
                     };
    
        private double[] getLocationCoords(){
            Criteria criteria = new Criteria();
            criteria.setHorizontalAccuracy(500);
            criteria.setVerticalAccuracy(500);
            LocationProvider locationProvider = LocationProvider.getInstance(criteria);
            Location location=null;
            new Thread(){
               public void run(){
                       locationProvider.getLocation(60);
               }
            }
            QualifiedCoordinates qualifiedCoordinates=location.getQualifiedCoordinates();
            double[] coords=new double[]{qualifiedCoordinates.getLatitude(),qualifiedCoordinates.getLongitude()}   ;
             return coords;
        }
    

    But I myself NullPointerException. Coordinates get successfully, if we run the location capability in different function, rather than the event thread.

    Please help me-

    In my opinion, which may be too complicate things a bit. I think he's trying to do is register a LocationListener with his object of LocationProvider. Callback methods, send a message to the UI event thread as follows (no need to spawn threads):

    UiApplication.getUiApplication().invokeLater( new Runnable() {
        public void run()
        {
            // This code will execute on the event thread
        }
    });
    

    EDIT: If your interval is short, you can consider implementing this executable as a class and store an instance in the front.

  • How to get the class Loader of Progress event

    I was charge test.swf file threw Loader class. How to get the class Loader of ProgressEvent, IOErrorEvent.

    function getLoader() {}
    var loader: Loader = new Loader();
    loader.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESS, progressHandler)
    loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, ioErrorHandler);
    var request: URLRequest = new URLRequest ("test.swf");
    Loader.Load (request);
    }
    function progressHandler(event:ProgressEvent):void {}

    get the class loader
    }

    function ioErrorHandler(event:IOErrorEvent):void {}
    get the class loader
    }
    getLoader()

    the event target has a property of charger:

    Event.Target.Loader

  • How to get mouse rollover events to filter?

    Hello

    I am tring to create a menu system for a video flv cue points chapters, the idea is that it will appear on a flvplayback component when you tap on a menu button. The menu itself button when a trigger movieclip is reversed. Now I have all the basics working, but my problem is that the movieclip shutter blocks the carousel mouse events. If I change the order of the movieclips so that the carousel is on top I get the carousel to mouse events, but only get part of the area of the movieclip trigger mouse events.

    The basic structure of my project is:


    Stadium

    FLVPlayback component

    Chapter Menu button - hidden state Initial

    Invisible Trigger Movieclip - bearing receives / events of deployment to bring up menu chapter

    Carousel - State Initial hidden

    My first question is, can I add roll during the events for a flvplayback component (I tried to use the method addEventListener in vain)?

    Second question is, is it possible to do the rollover movieclip via the carousel menu trigger event filter?

    Thank you

    eb_dev

    You are welcome.

    p.s. Please mark this thread as answered.

  • How to get user during script input

    Hello

    I would like to read an input value to the user. Anyone know how?

    Basically, I want to do something like show all hosts in a cluster, but the cluster name must be the value of entry...

    Thank you

    Yaniv

    This should do the job:

    Write-Host "Enter Cluster name:"
    $clusterName = Read-Host
    
  • How to get input on the arbitrary draw event data?

    Hi all

    I'm trying to draw a histogram on an arbitrary parameter (such as the effect of 'Levels'). Part of the draw is good, but I have a problem with the data in the input layer (param [0]).

    All I have to do now is read the entry about the event draw arbitrary data. But there is not the input on the draw event pointer. So I called the PF_CHECKOUT_PARAM() function to get the input data, and it works!

    When I test in AE, I created a layer A, and added some color correction effects to the layer before my effect added A layer. The problem is the input layer that read my effect is not the result of the previous effects that I applied before.

    Has any way to read the latest entry in the arbitrary event data?

    Thank you.

    the result of caching is a smart thing to do, but as you mentioned, when the

    the user sets the controls in a State that AE has already cached the image

    for, any rendering happens, and your user interface crashes on an irrelevant screen.

    (as is the case with 'levels' (or at least was))

    You can use PF_GetCurrentState PF_HasParamChanged during a draw event to

    know if your plug-in State param has changed sine the last call to draw.

    If so you can't, for a new record using PF_OutFlag_FORCE_RERENDER

  • How to get notification for Bluetooth and the event start?

    Hello

    Today, I try to compile an application bluetooth and my requirement as below

    When the user enable or disable bluetooth at this time here, that I need event, so I check this QBluetoothLocalDevice method here, I start only blletooth event, but I don't get bluetooth event so if you have any hesitate not solution reply me as soon as possible.

    Hi all

    I found the solution .

    void initBtDeviceCallBack(const int event, const char *bt_addr,
            const char *event_data) {
        if (event == BT_EVT_RADIO_INIT) {
            //bt_disc_start_inquiry(BT_INQUIRY_GIAC);
            qDebug() << "BT Device initiated from Services.....";
        } else if (event == BT_EVT_DEVICE_ADDED) {
            //qDebug() << "Remote Device Added : " << bt_addr;
        } else if (event == BT_EVT_NAME_UPDATED) {
            //qDebug() << "Remote Device Name Updated : " << event_data;
        } else if (event == BT_EVT_RADIO_SHUTDOWN) {
            qDebug() << "Bt Device shutdown from Services....";
        } else if (event == BT_EVT_DEVICE_CONNECTED) {
            qDebug() << "Bt Device Connected" << event_data;
        } else if (event == BT_EVT_DEVICE_DISCONNECTED) {
            qDebug() << "Bt Device Disconnected";
        }
    
        //qDebug() << "Device Added : " << event_data;
    }
    
  • I have a wireless optical mouse and I can't remove the usb of my laptop Gateway receiver. It is stuck there. How to get out?

    I have a wireless optical mouse and I can't remove the usb of my laptop Gateway receiver. It is stuck there. How to get out?

    Hello

    The unit just has USB slide out. If it is stuck, consult with a real computer store (the one that makes
    his own service in the House and not leeks and glances at a Best Buy or other stores) or gateway
    supported.

    Gateway drivers and downloads
    http://support.gateway.com/support/drivers/dlcenter.asp

    Technical support Gateway
    http://support.gateway.com/support/?cmpid=topNav

    Door Documents
    http://support.gateway.com/support/SUPINFO/index.asp?cmpid=topNav

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle=""><- mark="" twain="" said="" it="">

  • LOST laptop computer SOUNDHave WITH WINDOWS. His lost after automatic updates for VISTA operating system. Don't KNOW HOW TO GET sound BACK. CAN SOMEONE HELP ME?

    Have a laptop with the Windows Vista operating system.  After an automatic update of 3 steps software, I had sound.available and can not hear anything when I use Media Player.   I don't know how to get the sound to my laptop.  Can someone give me some advice on what I can do to get

    my sound back on my laptop?

    Thanks for your help, I appreciate it.

    Rmartinehp

    Hi rmartinehp,

    Thanks for posting your query in Microsoft Community.

    I understand that you are facing the issue with sound, after the automatic updates, you have lost the sound.

    Before you start the troubleshooting steps, I need the information required.

    1. this problem occurs with particular application?

    2. (http://windows.microsoft.com/en-US/windows7/Back-up-the-registry)

    I suggest you to see the links and check.

    No sound in Windows

    http://Windows.Microsoft.com/en-us/Windows/no-sound-help#no-sound=Windows-Vista&V1H=win8tab1&V2H=win7tab1&V3H=winvistatab1&v4h=winxptab1

    See also:

    Tips for solving common audio problems

    http://Windows.Microsoft.com/en-us/Windows-Vista/tips-for-fixing-common-sound-problems

  • How can get us a new operating system without having to buy one?

    Original title: Erased from the os

    My son has updated w 7 w 10 and somehow deleted the operating system. How can get us a new operating system without having to buy one?

    Hello

    Thank you for the update on the issue.

    Yes, you are right that DELL support should suggest your son even. But don't worry, finally, you are able to find the product key.

    Feel free to post on the forum if you have any concerns more associated with Windows. We will be happy to help you again.

    Kind regards

  • How to get windows 7 Professional operating for existing key?

    How to get windows 7 Professional operating system software for existing key

    For 5 years, Microsoft made it fairly easy for users of the Windows 7 operating system to get reinstall media. If you have lost your support disc or installation retail collection; either it has been damaged or defective; You can download a copy of the edition that you have licensed from a membership site called Digital River. More recently, Microsoft ended the availability to reinstall media that you can download as a. File ISO in Digital River, which is a digital reproduction of an optical disc.

    It was particularly convenient for people who could not easily get the manufacturer's recovery media, did not want to pay the fees required to get or preferred a clean configuration without the software packaged manufacturers or even a recovery partition does not work. It's easy to use, all you had to do was reinstall and reactivate using the product key located on the certificate of authenticity and download all the drivers on the manufacturers website.

    Given that this option is no longer available, what are your options? See the article for more details:

    How to: What are my options for Windows 7 reinstall media?

    Make sure you scroll down and read the section:

    What to do if you cannot get your manufacturer recovery media, refuse to use or to buy it or the Microsoft Software Recovery Website does not work?

  • During the import of my camera or a file in Lightroom 5 my pictures are too exposed by 1-2 stops, while they are well exposed on the screen of the device. How to get the "right-exposed images on the screen?

    During the import of my camera or a file in Lightroom 5 my pictures are too exposed by 1-2 stops, while they are well exposed on the screen of the device. How to get the "right-exposed images on the screen?

    There is an option in your Lightroom preferences, under the general tab, "treat JPEG files next to raw in form of images". If you have this option is checked, then Lightroom will import and view your first two and JPEG files. You use the active D-lighting on your camera? If you are, you must disable this feature.

  • How can getting error Code U44M1P7 during the upgrade, I fix?

    How can getting error Code U44M1P7 during the upgrade, I fix?

    Update product that you are trying to install?

    Is it compared to the creative or perpetual clouds?

    Please check following if you have creative clouds.

    http://helpx.Adobe.com/Creative-Suite/KB/error-u44m1p7-installing-updates-CCM.html

  • How to get a column using the logical AND operator on two columns?

    All columns are the VARCHAR2 data type.

    I got out of the table in this way:
    col1 col2
    True True
    True false
    False false
    but I want an extra column in this way:
    col1 col2 result
    True True True
    True false false
    Fake fake fake
    as the clear sound output shows this column resut is logical operator AND
    col1 and col2. How to get there?
    WITH t AS
         (SELECT 'True' col1, 'True' col2 FROM DUAL
          UNION ALL
          SELECT 'True' col1, 'False' col2 FROM DUAL
          UNION ALL
          SELECT 'False' col1, 'True' col2 FROM DUAL
          UNION ALL
          SELECT 'False' col1, 'False' col2FROM DUAL)
    SELECT col1,col2,CASE
              WHEN col1 = 'True' AND col2 = 'True'
                 THEN 'True'
              WHEN col1 = 'True' AND col2 = 'False'
                 THEN 'False'
                 WHEN col1 = 'False' AND col2 = 'True'
                 THEN 'False'
              WHEN col1 = 'False' AND col2 = 'False'
                 THEN 'False'
           END AS RESULT
      FROM t
    

Maybe you are looking for