Hi,

my problem is that during execution my presentation java applet is
flashing. There are many components which paint to a JPanel using it's
Graphics (.getGraphics). I think maybe the problem is that I don't
have any "paint everything now" routine..(I don't know which Java
routine to use, how I have to synchronize it etc..) Thanks for your
time and help.


I've the following code for the gui part (fe stands for "flocking-
enviroment", I'm making a flocking library):

The main loop:

(defn main [starting-fe]
  (let [first-fe starting-fe
        panel (new JPanel)
        frame (new JFrame)]

    ;; configuring panel
    (. panel setPreferredSize (new Dimension width height))

    ;; configuring frame
    (. frame add panel)
    (. frame pack)
    (. frame setVisible true)

    (loop [fe first-fe]
      (draw-fe fe panel)
      (Thread/sleep 100)
      (recur ((:update-f fe) fe)))))


Blanking the screen:

(defn blank-panel [panel]
    (let [g (. panel getGraphics)]
      (. g setColor (. Color BLACK))
      (. g fillRect 0 0 width height))))

At the end every boid drawed by this(called by the draw-fe function):

(defn draw-boid [boid panel]
    (let [[x0 x1] (:pos boid)]
      (let [g (. panel getGraphics)]
        (. g setColor (:color boid))
        (. g fillRect (- x0 2) (- x1 2) 5 5)))))

-- 
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