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:

Java 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):

Java 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:

Java 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