 (defn- display-size
   "Returns size of screen. If there are 2 or more screens it probably return size of
   default one whatever it means."
-  []
-  (let [bounds (.. (java.awt.GraphicsEnvironment/getLocalGraphicsEnvironment)
-                   getDefaultScreenDevice
-                   getDefaultConfiguration
-                   getBounds)]
-    [(.-width bounds) (.-height bounds)]))
+  ([] (display-size 0))
+
+  ([display]
+   (let [devices (.. (java.awt.GraphicsEnvironment/getLocalGraphicsEnvironment)
+                     getScreenDevices)]
+     (if (and (>= display 0) (< display (alength devices)))
+       (let [bounds (.. (aget devices display)
+                        getDefaultConfiguration
+                        getBounds)]
+         [(.-width bounds) (.-height bounds)])
+       (throw (IllegalArgumentException.
+                      (str "Invalid display definition: " display ". Displays are numbered starting from 0")))))))
 
 (defn- process-size
   "Checks that the size vector is exactly two elements. If not, throws
   an exception, otherwise returns the size vector unmodified."
-  [size]
-  (cond (= size :fullscreen) (display-size)
+  [size display]
+  (cond (= size :fullscreen) (display-size display)
         (and (coll? size) (= 2 (count size))) size
         :else (throw (IllegalArgumentException.
-                      (str "Invalid size definition:" size ". Was expecting :fullscreen or 2 elements vector: [x-size y-size].")))))
+                      (str "Invalid size definition: " size ". Was expecting :fullscreen or 2 elements vector: [x-size y-size].")))))
 
 (defn- to-method-name [keyword]
   "Converts keyword to java-style method symbol. :on-key-pressed => onKeyPressed"

  (PApplet/runSketch
   (into-array String
               (vec (filter string?
                   [(when (and (:bgcolor (meta applet))
                               (:present (meta applet)))
                     (str "--bgcolor" "=" (str (:bgcolor (meta applet)))))
                    "--hide-stop" title])))
   applet)
  (prepare-applet-frame applet title))


                      options
                      (safe-fns options))

        display           (or (:display options) 0)

        options           (merge (dissoc options :features)
                                 features)

        size              (process-size (:size options) display)
        title             (or (:title options) (str "Quil " (swap! untitled-applet-id* inc)))
        renderer          (or (:renderer options) :java2d)
        draw-fn           (or (:draw options) no-fn)
