After instantiating the bean, add components as drop targets using the addFileDropTarget() method. If the component is a java.awt.Container, then all elements contained within will be marked as a drop target as well. Using the FileDrop technique manually in your code will give you more options.
I'm releasing this code into the Public Domain. Enjoy.
Original author: Robert Harder, rharder@usa.net
Public Member Functions | |
FileDropBean () | |
Creates new FileDropBean. | |
void | addFileDropListener (FileDropListener listener) |
Register a listener for FileDropEvents. | |
void | addFileDropTarget (java.awt.Component comp) |
Registers a component as a drop target. | |
void | removeFileDropListener (FileDropListener listener) |
Unregister a listener for FileDropEvents. | |
boolean | removeFileDropTarget (java.awt.Component comp) |
Unregisters a component as a drop target. | |
Protected Member Functions | |
void | fireFileDropHappened (java.io.File[] files) |
Fires a FileDropEvent with the given non-null list of dropped files. | |
Private Attributes | |
javax.swing.event.EventListenerList | listenerList |
Static Private Attributes | |
static final long | serialVersionUID = -635164729709460738L |
Prevent serialization collisions. |
net.iharder.dnd.FileDropBean.FileDropBean | ( | ) |
Creates new FileDropBean.
void net.iharder.dnd.FileDropBean.addFileDropListener | ( | FileDropListener | listener | ) |
void net.iharder.dnd.FileDropBean.addFileDropTarget | ( | java.awt.Component | comp | ) |
Registers a component as a drop target.
If the component is a container, then all elements contained within will also be registered as drop targets, though only the outer container will change borders during a drag and drop operation (and even then, only if the container is a Swing component).
comp | The component to register as a drop target |
void net.iharder.dnd.FileDropBean.removeFileDropListener | ( | FileDropListener | listener | ) |
boolean net.iharder.dnd.FileDropBean.removeFileDropTarget | ( | java.awt.Component | comp | ) |
Unregisters a component as a drop target.
comp | The component to unregister |
void net.iharder.dnd.FileDropBean.fireFileDropHappened | ( | java.io.File[] | files | ) | [protected] |
Fires a FileDropEvent with the given non-null list of dropped files.
files | The files that were dropped |
final long net.iharder.dnd.FileDropBean.serialVersionUID = -635164729709460738L [static, private] |
Prevent serialization collisions.
javax.swing.event.EventListenerList net.iharder.dnd.FileDropBean.listenerList [private] |
Initial value:
new javax.swing.event.EventListenerList()