changeset 165:421dba17b7ed

Function to show View in a JFrame.
author Mikhail Kryshen <mikhail@kryshen.net>
date Wed, 26 Nov 2014 19:22:52 +0300
parents d91a7e0388da
children c5b37c658161
files src/indyvon/component.clj
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/indyvon/component.clj	Tue Nov 25 17:18:48 2014 +0300
+++ b/src/indyvon/component.clj	Wed Nov 26 19:22:52 2014 +0300
@@ -22,7 +22,7 @@
   (:use
    indyvon.core)
   (:import
-   (java.awt Graphics Component Dimension Color)
+   (java.awt Graphics Component Dimension Color EventQueue)
    (java.awt.geom Rectangle2D$Double)
    (javax.swing JFrame JPanel JOptionPane)))
 
@@ -65,5 +65,16 @@
     (.. (getContentPane) (add (make-jpanel view)))
     (.pack)))
 
+(defn ^JFrame show-view!
+  ([view]
+     (show-view! "Indyvon" view))
+  ([title view]
+     (let [f (atom nil)]
+       (EventQueue/invokeAndWait
+        #(doto (reset! f (make-jframe title view))
+           (.setDefaultCloseOperation javax.swing.JFrame/DISPOSE_ON_CLOSE)
+           (.setVisible true)))
+       @f)))
+
 (defn message [m]
   (JOptionPane/showMessageDialog (:component *scene*) m))