the watched directory is never added to the "dirs" map. The "watchDirectory" code should be changed to:
public void watchDirectory(DirChangedListener l, File dir,
boolean initialNotify) {
WatchedDir w = (WatchedDir) dirs.get(dir);
if (w == null) {
// New file; read its dir and stuff
String[] files = dir.list();
StringSortable.sortArray(files, SelectionSorter.get());
w = new WatchedDir(files);
dirs.put(dir, w);
dw.fw.watchFile(dw, dir);
} else if (w.who.indexOf(l) != -1) {
// duplicate request; ignore
return;
}
w.who.addElement(l);
// Fake notification?
if (initialNotify) {
for (int i = 0; i < w.files.length; ++i) {
l.handleFileCreated(this, dir, new File(dir, w.files[i]));
}
}
}
*Note that the important line is "dirs.put(dir, w);"