src/main/java/org/sikuli/slides/api/slideshow/FileDrop.java
private void makeDropTarget( final java.io.PrintStream out, final java.awt.Component c, boolean recursive )
    {
        // Make drop target
        final java.awt.dnd.DropTarget dt = new java.awt.dnd.DropTarget();
        try
        {   dt.addDropTargetListener( dropListener );
        }   // end try
        catch( java.util.TooManyListenersException e )
        {   e.printStackTrace();
            log(out, "FileDrop: Drop will not work due to previous error. Do you have another listener attached?" );
        }   // end catch
        
        // Listen for hierarchy changes and remove the drop target when the parent gets cleared out.
        c.addHierarchyListener( new java.awt.event.HierarchyListener()
        {   public void hierarchyChanged( java.awt.event.HierarchyEvent evt )
            {   log( out, "FileDrop: Hierarchy changed." );
                java.awt.Component parent = c.getParent();
                if( parent == null )
                {   c.setDropTarget( null );
                    log( out, "FileDrop: Drop target cleared from component." );
                }   // end if: null parent
                else
                {   new java.awt.dnd.DropTarget(c, dropListener);
                    log( out, "FileDrop: Drop target added to component." );
                }   // end else: parent not null
            }   // end hierarchyChanged
        }); // end hierarchy listener
        if( c.getParent() != null )
            new java.awt.dnd.DropTarget(c, dropListener);
        
        if( recursive && (c instanceof java.awt.Container ) )
        {   
            // Get the container
            java.awt.Container cont = (java.awt.Container) c;
            
            // Get it's components
            java.awt.Component[] comps = cont.getComponents();
            
            // Set it's components as listeners also
            for( int i = 0; i < comps.length; i++ )
                makeDropTarget( out, comps[i], recursive );
        }   // end if: recursively set components as listener
    }
private void makeDropTarget( final java.io.PrintStream out, final java.awt.Component c, boolean recursive )
    {
        // Make drop target
        final java.awt.dnd.DropTarget dt = new java.awt.dnd.DropTarget();
        try
        {   dt.addDropTargetListener( dropListener );
        }   // end try
        catch( java.util.TooManyListenersException e )
        {   e.printStackTrace();
            log(out, "FileDrop: Drop will not work due to previous error. Do you have another listener attached?" );
        }   // end catch
        
        // Listen for hierarchy changes and remove the drop target when the parent gets cleared out.
        c.addHierarchyListener( new java.awt.event.HierarchyListener()
        {   public void hierarchyChanged( java.awt.event.HierarchyEvent evt )
            {   log( out, "FileDrop: Hierarchy changed." );
                java.awt.Component parent = c.getParent();
                if( parent == null )
                {   c.setDropTarget( null );
                    log( out, "FileDrop: Drop target cleared from component." );
                }   // end if: null parent
                else
                {   new java.awt.dnd.DropTarget(c, dropListener);
                    log( out, "FileDrop: Drop target added to component." );
                }   // end else: parent not null
            }   // end hierarchyChanged
        }); // end hierarchy listener
        if( c.getParent() != null )
            new java.awt.dnd.DropTarget(c, dropListener);
        
        if( recursive && (c instanceof java.awt.Container ) )
        {   
            // Get the container
            java.awt.Container cont = (java.awt.Container) c;
            
            // Get it's components
            java.awt.Component[] comps = cont.getComponents();
            
            // Set it's components as listeners also
            for( int i = 0; i < comps.length; i++ )
                makeDropTarget( out, comps[i], recursive );
        }   // end if: recursively set components as listener
    }
private void makeDropTarget ( final java . io . PrintStream out , final java . awt . Component c , boolean recursive ) { // Make drop target
 final java . awt . dnd . DropTarget dt = new java . awt . dnd . DropTarget ( ) ; try { dt . addDropTargetListener ( dropListener ) ; } // end try
 catch ( java . util . TooManyListenersException e ) { e . printStackTrace ( ) ; log ( out , "FileDrop: Drop will not work due to previous error. Do you have another listener attached?" ) ; } // end catch
 // Listen for hierarchy changes and remove the drop target when the parent gets cleared out.
 c . addHierarchyListener ( new java . awt . event . HierarchyListener ( ) { public void hierarchyChanged ( java . awt . event . HierarchyEvent evt ) { log ( out , "FileDrop: Hierarchy changed." ) ; java . awt . Component parent = c . getParent ( ) ; if ( parent == null ) { c . setDropTarget ( null ) ; log ( out , "FileDrop: Drop target cleared from component." ) ; } // end if: null parent
 else { new java . awt . dnd . DropTarget ( c , dropListener ) ; log ( out , "FileDrop: Drop target added to component." ) ; } // end else: parent not null
 } // end hierarchyChanged
 } ) ; // end hierarchy listener
 if ( c . getParent ( ) != null ) new java . awt . dnd . DropTarget ( c , dropListener ) ; if ( recursive && ( c instanceof java . awt . Container ) ) { // Get the container
 java . awt . Container cont = ( java . awt . Container ) c ; // Get it's components
 java . awt . Component [ ] comps = cont . getComponents ( ) ; // Set it's components as listeners also
 for ( int i = 0 ; i < comps . length ; i ++ ) makeDropTarget ( out , comps [ i ] , recursive ) ; } // end if: recursively set components as listener
 }
END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
END 2007 - 09 - 12 Nathan Blomquist -- Linux ( KDE / Gnome ) support added .