   (bind-window-key window "ADD" #(swap! zoom-atom update-in [:zoom] inc))
   (bind-window-key window "SUBTRACT" #(swap! zoom-atom update-in [:zoom] dec)))
   
-(defn display-follow [canvas reference]
+(defn display-follow [panel reference]
   (add-watch reference "display"
     (fn [_ _ _ _]
-      (.repaint canvas))))
-
-(defn main-canvas [screen-state available-tiles]
+      (.repaint panel))))
+
+(defn main-panel [screen-state available-tiles]
   (doto
-    (proxy [Canvas] []
-      (paint [^Graphics g] (paint-screen this screen-state available-tiles)))
-    (.setBackground Color/BLACK)))
+    (proxy [JPanel] []
+      (paintComponent [^Graphics graphics]
+                      (proxy-super paintComponent graphics)
+                      (paint-screen graphics screen-state available-tiles)))
+    (.setBackground Color/BLACK)
+    ))
     
 (defn main-frame []
   (doto (JFrame. "Slide Explorer II")

(ns slide-explorer.display
  (:import (javax.swing AbstractAction JComponent JFrame JLabel KeyStroke)
           (java.awt Canvas Color Graphics Graphics2D RenderingHints Window)
           (java.awt.event ComponentAdapter KeyAdapter KeyEvent MouseAdapter
                           WindowAdapter)
           (java.awt.image BufferedImage WritableRaster)

(defn show []
  (let [screen-state (atom (sorted-map :x 0 :y 0 :z 0 :zoom 0))
        available-tiles (agent {})
        panel (main-panel screen-state available-tiles)
        frame (main-frame)]
    (def at available-tiles)
    (def ss screen-state)
    (def f frame)
    (def pnl panel)
    (.add (.getContentPane frame) panel)
    (setup-fullscreen frame)
    (handle-drags panel screen-state)
    (handle-wheel panel screen-state)
    (handle-resize panel screen-state)
    (handle-zoom frame screen-state)
    (display-follow panel screen-state)
    (display-follow panel available-tiles)
    (display-follow panel angle)
    frame))


