/** * Sets the {@code FileDrop} as enabled or disabled. * * @param active {@code true} if the {@code FileDrop} should become active, and {@code false} otherwise * @since 1.1 */ public void setActive(boolean active) { if (supportsDnD()) makeDropTargetActive(out, c, recursive, active); }
private void makeDropTargetActive(final PrintStream out, final Component c, boolean recursive, boolean active) { DropTarget dropTarget = c.getDropTarget(); if (dropTarget != null) dropTarget.setActive(active); if (c.getParent() != null) { DropTarget parentDropTarget = c.getDropTarget(); if (parentDropTarget != null) c.getDropTarget().setActive(active); } if (recursive && c instanceof Container) { // Get the container Container cont = (Container) c; // Get its components Component[] comps = cont.getComponents(); // Set its components as listeners also for (Component comp : comps) makeDropTargetActive(out, comp, recursive, active); } }