/** * 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); }
/** * Removes the drag-and-drop hooks from the component and optionally from * the all children. You should call this if you add and remove components * after you've set up the drag-and-drop. * * @param out Optional {@link PrintStream} for logging drag and drop * messages * @param c The component to unregister * @param recursive Recursively unregister components within a container * @return {@code true} if hooks were removed, and {@code false} otherwise * @since 1.0 */ public static boolean remove(PrintStream out, Component c, boolean recursive) { // Make sure we support dnd. if (supportsDnD()) { log(out, "FileDrop: Removing drag-and-drop hooks."); c.setDropTarget(null); if (recursive && (c instanceof java.awt.Container)) { Component[] comps = ((java.awt.Container) c).getComponents(); for (Component comp : comps) remove(out, comp, recursive); return true; } else { return false; } } else { return false; } }
if (supportsDnD()) { this.out = out; this.c = c;