Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-05-2009, 12:56 PM
Member
 
Join Date: Jul 2009
Posts: 7
Rep Power: 0
Mikey_S is on a distinguished road
Default Drag & Drop, invalidDnDException, totally urgent.
Hey there folks, I'm working on a GUI Checkers project for college... everything works flawlessly on windows, but fails to do so on Linux (latest Ubuntu).

When debugging with Netbeans, the following comes up:

Code:
Exception in thread "AWT-EventQueue-0" java.awt.dnd.InvalidDnDOperationException: Cannot find top-level for the drag source component
        at sun.awt.X11.XDragSourceContextPeer.startDrag(XDragSourceContextPeer.java:111)
        at sun.awt.dnd.SunDragSourceContextPeer.startDrag(SunDragSourceContextPeer.java:111)
        at java.awt.dnd.DragSource.startDrag(DragSource.java:306)
        at java.awt.dnd.DragSource.startDrag(DragSource.java:376)
        at checkers.GUICheckers.GUIStone$DragGestureRecognizer.dragGestureRecognized(GUIStone.java:49)



I can't find anything related to that exact exception, so I thought i'd just ask
I can't find anything related to that exact exception, so I thought i'd just ask in here...

Just to give some information about the overall layout tree:
I have a frame (JFrame), which contains a big JPanel which fills the whole frame.
The big JPanel is using a border layout, and contains a scoreboard panel (at the top), a right panel which contains information regarding the current match,
a status panel (at the bottom) and of course, the main Checkers board at the center.

The Checkers board (extends JPanel and using an 8x8 grid layout) is made of little JPanels, each panel represents a board square.

on the squares that currently contain a Checkers piece I add a JLabel which contains the right piece image and which listens to drags.

The following code is located inside the GUIStone class (extends JLabel):

Code:
class DragGestureRecognizer implements DragGestureListener {
        public void dragGestureRecognized(DragGestureEvent e) {
            /* check whether the dragging is legal */
            Component c = getParent();
            if (c instanceof GUICheckersSquare) {
                GUICheckersSquare sqr = (GUICheckersSquare)c;
                sqr.remove(GUIStone.this);
 
                GUICheckersGlass glassPane = mainCont.getGlassPane();
                glassPane.setImage((ImageIcon)GUIStone.this.getIcon());
                glassPane.repaint();
 
                String coords = sqr.getPos().toStringNoFormat();
                StringSelection text = new StringSelection(coords);
                DragSource.getDefaultDragSource().startDrag(
                        e, null, null, null, text, new DragHandler());
 
                mainCont.getGlassPane().setVisible(true);
 
            }
and the DragHandler class looks like this:

Code:
class DragHandler implements DragSourceListener {
        public void dragDropEnd(DragSourceDropEvent e) {
            mainCont.getGlassPane().setVisible(false);
 
            if (!e.getDropSuccess()) {
                GUICheckersSquare sqr = mainCont.getGUISqrByPos(stn.getPos());
                sqr.add(GUIStone.this);
                sqr.repaint();
            }
            // for debugging
            // System.out.println("dragDropEnd");
        }
 
        public void dragEnter(DragSourceDragEvent e) {
            mainCont.getGlassPane().setVisible(true);
            // for debugging
            // System.out.println("dragEnter");
        }
 
        public void dragExit(DragSourceEvent e) {
            mainCont.getGlassPane().setVisible(false);
 
            // for debugging
            // System.out.println("dragExit");
        }
        public void dragOver(DragSourceDragEvent e) {
            GUICheckersGlass glassPane = mainCont.getGlassPane();
            glassPane.repaint();
 
            // for debugging
            // System.out.println("dragOver");
        }
        public void dropActionChanged(DragSourceDragEvent e) {
            mainCont.getGlassPane().setVisible(false);
 
            // for debugging
            // System.out.println("dropActionChanged");
        }
    }
}
Any idea how can I solve this?
again, this works just fine in windows.

and for anyone who would like to see the layout, please let me know (I just cant post links right now, because I dont have 20 posts yet .



Thanks!, Mikey
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drag and Drop(URGENT) simmi AWT / Swing 5 07-10-2009 12:16 PM
Drag and Drop Issue kirly Advanced Java 1 04-16-2009 06:04 AM
Drag and drop thayalan AWT / Swing 1 02-16-2009 04:04 PM
Drag and drop abhivenugopal JavaServer Pages (JSP) and JSTL 0 01-30-2008 03:10 PM
help with drag and drop on JList ysl530 AWT / Swing 3 08-13-2007 06:38 PM


All times are GMT +2. The time now is 04:35 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org