Hi all,

I've had this unbelievable problem for some time now but I'm sick and tired of ignoring it! It is literally driving nuts...Due to the nature of the problem my terminal hangs and Eclipse crashes altogether (potentially losing work)!

So what is the problem...Well I really don't have a clue! it is pretty obvious that my code is waiting on something but it only happens when I've got a dependency on a namespace of mine which uses seesaw. It is basically my gui...the bad behaviour is exhibited every time I try to reload my namespace after having opened a JFrame regardless of having done anything on the frame! I mean the same happens if I open it and close it straight after!

anyway, I managed to mock the behaviour with a minimal example:
-------------------------------------------------------------------------------------------------------------

(ns Clondie24.games.dummy
          (:require [Clondie24.lib.gui :as gui]))

(def details {:name 'Dummy
              :players 2
              :arena-size [420 :by 505]
              :tile-size 133})

(defn -main
"Starts a graphical (swing) Chess game."
[& args]
(gui/show-gui! details))


(ns Clondie24.lib.gui
    (:require [Clondie24.lib.util :as ut]
              [Clondie24.lib.core :as core]
              [seesaw.core :as ssw]
              [seesaw.chooser :as choo])
    (:import  [java.awt AlphaComposite Graphics Graphics2D Toolkit]
              [java.awt.event MouseEvent]
              [javax.swing SwingWorker UIManager]) )

(def curr-game (promise))
(def status-label (ssw/label :id :status :text "Ready!"))

(defn draw-tiles [d ^Graphics g]
  (let [w (ssw/width d)
        h (ssw/height d)
        tile-size (:tile-size @curr-game)
        tiles (map vector (for [x (range 0 w tile-size)
                                y (range 0 h tile-size)] [x y])
                          (cycle (:alternating-colours @curr-game)))]
(when (:alternating-colours @curr-game)
  (doseq [[[x y] c] tiles]
       (.setColor g c)
       (.fillRect g x y tile-size tile-size)) )
 (draw-grid d g)
 (draw-images g)
 (highlight-rects g)))

(def canvas "The paintable canvas - our board"
 (ssw/canvas
    :paint draw-tiles
    :id :canvas
    :listen [:mouse-clicked (fn [e] (when-not (and (:block? @knobs)
(realized? curr-game))
                                              (canva-react e)))]
    ))

(defn arena "Constructs and returns the entire arena frame." []
 (ssw/frame
    :title "Clondie24 Arena"
    :size  (:arena-size @curr-game)
    :resizable? false
    :on-close :exit
    :menubar  nil ;(make-menubar)
    :content  (ssw/border-panel
               :border 10
               :hgap 10
               :vgap 10     ;;IGNORE ALL THIS FOLLOWING CODE TO SAVE TIME
               :north  (ssw/horizontal-panel :items
[(ssw/button :text "Undo" :listen [:action (fn [e] (when-not (:block? @knobs)
(do (refresh :highlighting? false
:hint nil)
(undo!) (ssw/repaint! canvas))))]) [:fill-h 10]
(ssw/button :text "Clear" :listen [:action (fn [e] (when-not (:block? @knobs)
(do (refresh :highlighting? false
:hint nil)
(clear!) (ssw/repaint! canvas))))]) [:fill-h 10]
(ssw/button :text "Available Moves" :listen [:action (fn [e] (when-not (:block? @knobs) (do (refresh :highlighting? true
:hint nil)
(ssw/repaint! canvas))))]) [:fill-h 10]
(ssw/button :text "Hint" :listen [:action (fn [e] (when-not (:block? @knobs) (do (knob! :highlighting? false)
(with-busy-cursor canvas
(hint (:pref-depth @curr-game)) :hint))))]) [:fill-h 10]])
               :center canvas
               :south  status-label)))


(defn show-gui! "Everything starts from here." [game-map]
(deliver curr-game game-map) ;firstly make the gui aware of what game we want it to display
   (ssw/invoke-later
     (doto (arena) ssw/show!)))

---------------------------------------------------------------------------------------------------------------------------

any thoughts / feedback are greatly welcome. I cannot see why such a standard setup would hang after trying to reload the dummy namespace. everything reloads just fine as long as i don't show anything on screen...scary stuff!

thanks in advance...

Jim



--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to