API for seesaw.invoke - Seesaw


Full namespace name: seesaw.invoke

Overview





Public Variables and Functions



invoke-later

macro
Usage: (invoke-later & body)
Equivalent to SwingUtilities/invokeLater. Executes the given body sometime
in the future on the Swing UI thread. For example,

  (invoke-later
    (config! my-label :text "New Text"))

Notes:

  (seesaw.core/invoke-later) is an alias of this macro.

See:

  http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeLater(java.lang.Runnable) 


invoke-now

macro
Usage: (invoke-now & body)
Equivalent to SwingUtilities/invokeAndWait. Executes the given body immediately
on the Swing UI thread, possibly blocking the current thread if it's not the Swing
UI thread. Returns the result of executing body. For example,

  (invoke-now
    (config! my-label :text "New Text"))

Notes:
  Be very careful with this function in the presence of locks and stuff.

  (seesaw.core/invoke-now) is an alias of this macro.

See:
  http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeAndWait(java.lang.Runnable) 


invoke-soon

macro
Usage: (invoke-soon & body)
Execute code on the swing event thread (EDT) as soon as possible. That is:

  * If the current thread is the EDT, executes body and returns the result
  * Otherise, passes body to (seesaw.core/invoke-later) and returns nil

Notes:

  (seesaw.core/invoke-soon) is an alias of this macro.

See:
  (seesaw.core/invoke-later)
  http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeLater(java.lang.Runnable) 


signaller

macro
Usage: (signaller args & body)
Convenience form of (seesaw.invoke/signaller*).

A use of signaller* like this:

  (signaller* (fn [x y z] ... body ...))

can be written like this:

  (signaller [x y z] ... body ...)

See:
  (seesaw.invoke/signaller*)


signaller*

function
Usage: (signaller* f)
Returns a function that conditionally queues the given function (+ args) on 
the UI thread. The call is only queued if there is not already a pending call
queued. 

Suppose you're performing some computation in the background and want
to signal some UI component to update. Normally you'd use (seesaw.core/invoke-later)
but that can easily flood the UI thread with unnecessary updates. That is,
only the "last" queued update really matters since it will overwrite any
preceding updates when the event queue is drained. Thus, this function takes
care of insuring that only one update call is "in-flight" at any given
time.

The returned function returns true if the action was queued, or false if
one was already active.

Examples:

  ; Increment a number in a thread and signal the UI to update a label
  ; with the current value. Without a signaller, the loop would send
  ; updates way way way faster than the UI thread could handle them.
  (defn counting-text-box []
    (let [display (label :text "0")
          value   (atom 0)
          signal  (signaller* #(text! display (str @value)))]
      (future
        (loop []
          (swap! value inc)
          (signal)
          (recur)))
      label))

Note:

  You probably want to use the (seesaw.invoke/signaller) convenience
  form.

See:
  (seesaw.invoke/invoke-later)
  (seesaw.invoke/signaller)
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.