 
 (def prefs (.. Preferences userRoot (node "DLLAutoReloader")))
 
+(def control-frame (atom nil))
+
 (defn startup
+  "Create the control frame and activate directory watching."
   []
   (let [frame (proxy [JFrame] []) ; use proxy to get unique JFrame class
         path (.get prefs "dir" nil)

    (when path
      (activate path))
    (doto frame
      (.setBounds 100 100 700 50)
      (.setResizable false)
      (GUIUtils/recallPosition)
      (.setTitle "DLL Auto Reloading"))
    (.addActionListener path-button
                        (proxy [ActionListener] []
                          (actionPerformed [e]
                            (when-let [dir (file (choose-dll-dir))]
                              (let [path (.getAbsolutePath dir)]
                              (.setText path-button path)
                              (activate path)
                              (.put prefs "dir" path))))))
    (doto (.getContentPane frame)
      (.add path-button))
    (.show frame)))

(defn showPlugin [this]
  (startup))

(defn handle-exit []
  (stop))

           (org.micromanager.utils FileDialogs FileDialogs$FileType
                                   GUIUtils JavaUtils)))


(defn devices-in-each-module
  "Returns a map of each module to a vector of loaded devices.
