Image Drag'n'Drop error

Hello
so... he is the deal:
based on that: http://java-buddy.blogspot.com/2012/03/javafx-20-implement-gesturetarget-of.html i made some simple app that loads pictures from files.
whats important about this is this:
HBox targetBox = new HBox();and this
targetBox.getChildren().add(dbImageView);now. this works. but if i use fxml file, i cant force it to do its job.
HBox was added to the scene using scene builder and it looks like this:
<HBox id="hBox1" fx:id="targetBox" layoutX="14.0" layoutY="14.0" prefHeight="221.0" prefWidth="544.0" />and then in my main class, extending Application am trying to do this:
@FXML HBox hBox1; or @FXML HBox targetBox; (tried both ways)then
    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("sceneBuilder.fxml"));
        Scene scene = new Scene(root);
        setupGestureTarget(scene, hBox1); //taken from tutorial mentioned above
        stage.setScene(scene);
        stage.show();
    }it runs, i try to drag some image from explorer folder into the scene and BANG
onDragDropped
java.lang.NullPointerException
     at mzlike.MZlike$2.handle(MZlike.java:79)
     at mzlike.MZlike$2.handle(MZlike.java:64)
     at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
     at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
     at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
     at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
     at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
     at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
     at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
     at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
     at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
     at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
     at javafx.event.Event.fireEvent(Unknown Source)
     at javafx.scene.Scene$DnDGesture.fireEvent(Unknown Source)
     at javafx.scene.Scene$DnDGesture.processTargetDrop(Unknown Source)
     at javafx.scene.Scene$DnDGesture.access$4300(Unknown Source)
     at javafx.scene.Scene$DropTargetListener.drop(Unknown Source)
     at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleDragDrop(Unknown Source)
     at com.sun.glass.ui.View.handleDragDrop(Unknown Source)
     at com.sun.glass.ui.View.notifyDragDrop(Unknown Source)
     at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
     at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
     at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source)
     at java.lang.Thread.run(Thread.java:722)
Exception in thread "JavaFX Application Thread" Ewhere 79 line is targetBox.getChildren().add(dbImageView);i can upload my whole project somewhere, if you guys want.
i'd really be thankful for any help
best regards

ok so i did something like this:
public class Sample implements Initializable {
    @FXML HBox hBox1;
    @FXML
    private void handleButtonAction(ActionEvent event) {
        System.out.println("You clicked me!");
        if(event.getSource() instanceof MenuItem){
            System.out.println("Source is MenuItem");
            MenuItem source = (MenuItem) event.getSource();
            System.out.println("Source text is = " + source.getText());
        //label.setText("Hello World!");
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
        setupGestureTarget(hBox1);
    void setupGestureTarget(final HBox targetBox){
        targetBox.setOnDragOver(new EventHandler <DragEvent>() {
            @Override
            public void handle(DragEvent event) {
                /* data is dragged over the target */
                System.out.println("onDragOver");
                Dragboard db = event.getDragboard();
                if(db.hasFiles()){
                    event.acceptTransferModes(TransferMode.ANY);
                event.consume();
        targetBox.setOnDragDropped(new EventHandler <DragEvent>() {
            @Override
            public void handle(DragEvent event) {
                /* data dropped */
                System.out.println("onDragDropped");
                Dragboard db = event.getDragboard();
                if(db.hasFiles()){
                    for(File file:db.getFiles()){
                        String absolutePath = file.getAbsolutePath();
                        Image dbimage = new Image(absolutePath);
                        ImageView dbImageView = new ImageView();
                        dbImageView.setImage(dbimage);
                        targetBox.getChildren().add(dbImageView);
                    event.setDropCompleted(true);
                }else{
                    event.setDropCompleted(false);
                event.consume();
}and this is the outcome
May 17, 2012 11:27:41 AM javafx.fxml.FXMLLoader logException
SEVERE: java.lang.NullPointerException
/C:/test_workspace/NetBeans/MZlike/build/classes/mzlike/sceneBuilder.fxml:-1
  at mzlike.Sample.setupGestureTarget(Sample.java:61)
  at mzlike.Sample.initialize(Sample.java:56)
  at javafx.fxml.FXMLLoader.load(Unknown Source)where line 61 is
        targetBox.setOnDragOver(new EventHandler <DragEvent>() Edited by: Radosław on 2012-05-17 02:46

Similar Messages

  • Does image Drag N Drop work on WinXP?

    I tried the program from techtips
    http://java.sun.com/developer/JDCTechTips/2003/tt0318.html
    and I can't drag an image file from window explorer and drop it to the program but
    I can drag n drop the image if I launch two instances of this program. Any idea?

    I tried the program from techtips
    http://java.sun.com/developer/JDCTechTips/2003/tt0318.html
    and I can't drag an image file from window explorer and drop it to the program but
    I can drag n drop the image if I launch two instances of this program. Any idea?

  • How do I stop finder from opening a new window every time I download an image (drag and drop)?

    Before I updated my computer I could drag and drop a new image from the internet to wherever I wanted on the desktop. Now when I download a new image from the internet it opens the "Desktop" finder windo. Also it systematically downloads the new image to be placed underneath the last downloaded/organized file. How do I stop it from doing both of these things?

    Try relaunching the Finder > Relaunch Finder… from the Mac OS X Finder

  • Drag and Drop Error

    When I try to drag and drop folders in SharePoint 2013, I get a message 'We can't upload folders or empty files' but I can drag and drop the individual files.

    Hi,
    According to your post, my understanding is that you wanted to drag the folders to SharePoint 2013.
    It is by design, we could not drag the folders to the site directly.
    As workarounds, you can use the following alternate solutions.
    1 Use the conventional Windows Explorer View - To Open Windows Explorer click on Upload
    Next in the Add Documents popup click on “Upload Files using windows Explorer Instead” to Open the Windows explorer view where you can
    Drag and Drop folders.
    2. Map the Document Library as Network Drive – You can Map any document library as a network drive and then
    drag and drop folders to it
    When you Map a document Library as a Network drive, you might see an error because of the missing “Desktop Experience” feature in Windows Server 2012
    3. Using SYNC Option - In SharePoint 2013, you can make any Document Library SYNC to your Local
    Folder (Including the SkyDrive PRO Library) to work with documents Offline.
    Once the Library is synced users can Open, Edit and Add Files and Folders to the synced Library
    Folder that gets created on your Local.
    These additions can be synced back to the Library either every time when you connect to
    SharePoint or On-Demand with “Sync now”.
    Thanks & Regards,
    Jason 
    Jason Guo
    TechNet Community Support

  • Image drag and drop

    Hi all,
    I am writing a program, with 2 JPanels, the first one is with 4 images (JLabel), I need to drag the images and drop on second JPanel. When the image is dropped, it should also allow dragging to desired position in that JPanel(through MouseMotionListener).
    I read a lot of examples about DnD, TransferHandler, I knew how to implement drag and drop between JPanels, but still have no idea how to implement both. Can anyone advise a brief idea how can I do.
    Thank you so much....

    Read this: http://forum.java.sun.com/thread.jsp?forum=57&thread=516990
    It shouldn't be a big streach to convert the panel to an image.
    If you have problems after trying this out, repost.

  • Cap 4 Corrupts on image drag and drop

    Hi All,
    I have run into a very frustrating problem with Cap 4. I will be working along creating slides then when I drag and drop a JPEG image into the movie:
    1. the timeline on that side disappears 2.the project corrupts and will not save or open previously saved project.
    Anyone have any ideas?
    Thanks

    Hi there
    Perhaps try first saving the image, then using the Insert > Image menu command. See if that results in better behavior.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • LR v1.0 - Qimage interaction (no image drag and drop)

    I am able to drag and drop image files from Bridge-CS2 to Qimage templates for printing (I am also able to drag images from Bridge2-CS3 beta to Qimage.)
    I have NOT been able to drag the same image files from LR v1.0 to Qimage (the cursor shows the image being dragged until leaving the LR window, then the cursor turns to a slash-circle - "NO").
    Anyone had success, or similar problems?
    Thanks.
    Joe

    Try using Qimage in export actions and export to it.

  • Drag and Drop error - icons are stuck to the cursor

    For the last few days when I try to use drag and drop, the items stick to the cursor and cannot be dislodged without a force quit or a reboot. That is they drag, but they do not drop. This is really sub-optimal.
    Has this happened to anyone else? How do I fix it?

    Idiot question - How do I re-install Leopard? No matter what I do, it kicks the disk out on restart. I have tried using the 'install' command on the disk, nothing. It kicks the disk out and boots from the hard drive. I have tried rebooting holding down the 'c' key to force it to read from the drive, it still kicks the disk out and boots from the hard drive. What else should I do?
    I researched back further and found another thread where people were complaining of the same drag and drop issue: http://discussions.apple.com/thread.jspa?messageID=6446208
    Someone suggested a solution involving permissions. I fixed my permissions. Drag and drop is still not working.
    There was also a set of commands to type into terminal that would supposedly fix the issue, or perhaps it was a Spotlight issue that the thread had morphed into. I did that. Drag and drop is still not working.
    Am I just totally hosed? Help!

  • Combining PDFs - drag and drop errors

    We regularly assemble large numbers of documents by gathering pages from 5 or more seperate documents using various drag and drop methods.
    As it's a simple collation, we'd been able to simply drag a document icon from the finder to the corrent point in the final documents pages/thumbnail view to add it.
    This works well when combining two documents - but when you combine three or more, you get a very strange behaviour:
    Acrobat will continue to re-copy content from the first drag and dropped document, rather than content from the subsequent documents!
    And this drives us crazy.
    Our workaround requires us to open each document one at a time in thumbnail view and drag between these views - which seems pointless when you're moving the entire content of each document into the other.
    Anyone else experienced this issue? Anyone have any insights?
    (Running Acrobat 8.2.5)
    regards

    http://kb2.adobe.com/cps/401/kb401518.html

  • Preview image drag and drop from offline master

    I've always loved the ability to drag and drop previews even though the master is offline.
    Why can't i do this in ap3?
    It seems to be hit or miss, mostly miss for me.
    It's great to take home a library of offline masters and quickly mock-up layouts using ap1-2
    Any solutions?

    You started the thread off basically telling everyone that drag out of the previews didn't work if the masters were offline in Aperture 3. Rereading your posts I don't really see a question in there anywhere.
    This post is a support question. It is not my intention to make broad statements that this behavior is widespread for every ap3 user. The apple support forums are radically different and I'm a bit confused as to how this new system works.
    Frank Caggiano wrote:
    Well have you run any of the basic trouble shooting tips show at  http://support.apple.com/kb/HT3805 for s start?
    Now if you're interested in trying to get this fixed I'd hold off on going into the library and maybe give us the backstory. I still don't know what equipment you're on or how this all started.
    I have done all those steps including using disk utility to repair permissions.
    This behavior is consistent across 3 computers with their own unique ap3 licenses:
    2011 17" MacBook Pro
    2010 Mac Mini
    2010 15" MacBook Pro
    I've upgraded all computers to Aperture 3 5 months ago and I've seen this issue ever since.

  • Drag and drop error in new acrobat pro 11

    I would be able to drag pages from a PDF opened in Internet explorer and drop the pages I wanted to a PDF opened in acrobat pro. In version 10 this worked but now in 11 it does not. How do i get this function to work again?

    Could you post a screenshot of what folders you're talking about? You have to move events. It should look something like this:

  • Drag and Drop Image into JTable

    I was wondering if anyone can tell me if it is possible to have an image dragged and dropped into a JTable where the single image snaps to multiple columns and rows?
    Thank you.

    Can anyone point me in the right direction for doing the following:
    Drag and drop an image into a JTable where the single image snaps to multiple columns and rows.
    Thanks.

  • How to add imge to another image box by drag and drop

    Hi all
       i am using flex 3.and my problem is to drag an image and drop to another box or image what ever.just need to display the copy of the source image in its drop target.is it possible drag an image?if it is then how?please help me.
    thanks and regards

    there are examples of image dragging and dropping here:
    http://www.adobe.com/devnet/flex/quickstart/adding_drag_and_drop/
    i imagine for your problem, you want the final example, and instead of passing across an integer value, you want to pass across the image source.

  • Embedded drag and drop not working

    Hi,
    Hoping someone can help as have got 90% of the way through a project and hit a wall at the final (end-of-level-baddie) problem.
    I'm currently embedding old AS2 activities (build by a second party - now not operating/contactable) into a new AS3 menu system.
    Most of them I've managed to port across and embed without issue. Unfortunately embedding the drag and drop activity is proving to be, for want of a better phrase, a complete drag.
    I've managed to decompile the code, so have put a few trace statements in to find out what might be going wrong. Looking in the collision detection part of the code, the problem appears to be that when the activity is embedded, although the index of the drag clip is returned fine with its corresponding index number, the index of the drop clip is returned as 'undefined'.
    The activity works fine in a standalone flash player, with both indexes returning their respective numbers. However not so when it's embedded.
    I'm guessing that this is a levels issue, but is there any easy way that I can force the AS2 drag and drop game to act as self-contained and ignore its parent holding clip?
    Thanks in advance

    Hi kglad,
    Thanks for replying (you've helped me out before :-)  )
    A search of the classes reveals only one mention of getDepth() on a text field, which is irrelevant at the mo (as the engine's just creating image drag and drops)
    The main activity stage is created by an EngineClass (which drives all the activities I've been adapting, but wasn't a problem with less layer critical ones).
    There are three lines I can see where the activity stage is created using 'getNextHighestDepth()'
    this.mWhere.createEmptyMovieClip("activity_mc", this.mWhere.getNextHighestDepth());
    this.mWhere.createEmptyMovieClip("activityMask_mc", this.mWhere.getNextHighestDepth());
    this.mWhere.createEmptyMovieClip("toolbars_mc", this.mWhere.getNextHighestDepth());
    All the drags and drops are then created within this activity_mc. When I run the activity as standalone (where it works), and drag an item onto a drop zone, the traces I set up on the Drag and Drop items report back the following:
    DragObject: _level0.activity_mc.container_mc.dropItem2.dropSkin.greyBorder.whiteBG
    DropArea: _level0.activity_mc.container_mc.dropItem2.dropSkin.greyBorder
    When I run it embedded in the AS2 wrapper it then fires back the following after an attempted drop:
    DragObject: undefined
    DropArea: undefined
    ...and the item refuses to drop on the dropzone, returning to where it came from.
    The tiny amount of knowledge I have makes me (probably mistakenly) assume that if I could place the activity_mc layer on root, then everything would be contained within the embedded clip and the layering wouldn't go so wonky. But in reality I've got no idea! To make matters worse, the original drag and drop activity is itself inside another as2 wrapper which contains some navigation buttons...

  • When i drag and drop an image on my site. it gives the following error. "Unable to access local files due to browser security settings. To overcome this, follo"

    I am using the firefox version 17 and when i drag and drop an image on my website. It gives me the following error.
    Unable to access local files due to browser security settings. To overcome this, follow these steps: (1) Enter "about:config" in the URL field; (2) Right click and select New->Boolean; (3) Enter "signed.applets.codebase_principal_support" (without the quotes) as a new preference name; (4) Click OK and try loading the file again. Or go to the homepage for a link to the tutorial on how to do it.
    I have completed the above steps and it is still showing the same error message. Any help would be highly appreciated.
    Thanks.

    Thanks kumars ,
    I have a specific drag and drop area on our website. This works fine for all earlier releases of Firefox after these security settings
    "(1) Enter "about:config" in the URL field; (2) Right click and select New->Boolean; (3) Enter "signed.applets.codebase_principal_support" (without the quotes) as a new preference name; (4) Click OK and try loading the file again."
    Bust these settings not work for me in Firefox 17.
    Yes the drag and drop functionality is java script based and i am not using any script blocker addons.

Maybe you are looking for