1. Meikel Brandmeyer
  2. jazz

Overview

HTTPS SSH
        _________
        ______  /_____ ___________
        ___ _  /_  __ `/__  /__  /
        / /_/ / / /_/ /__  /__  /_
        \____/  \__,_/ _____/____/

# Jazz – a JGoodies Forms DSL for Clojure #

*Jazz* provides a small embedded DSL for the JGoodies Forms library.
One can specify the layout of the form programmatically while *Jazz*
takes care of building the form and all the boilerplate.

## Example ##

This is a small example demonstrating the features of the library.

        (import '(javax.swing JButton JFrame JTextField))
        (require '[de.kotka.jazz :as forms])

        (def field1 (atom ""))
        (def field2 (atom nil))
        (def field3 (atom 0))
        (def field4 (atom false))

        (def field-printer (proxy [java.awt.event.ActionListener] []
                             (actionPerformed [_] (doseq [field [field1 field2
                                                                 field3 field4]]
                                                    (println @field)))))

        (def printer-button (doto (JButton. "Print!")
                              (.addActionListener field-printer)))

        (def panel
          (forms/make-panel
            [{:label     "Label1" :constraints "1, 1"}
             {:editor    String   :constraints "3, 1, 3, 1" :atom field1}
             {:label     "Label2" :constraints "1, 3"}
             {:editor    :Enum    :constraints "3, 3, 3, 1"
              :atom field2 :choices ["Abc" "Fgh" "Xyz"]}
             {:label     "Label3" :constraints "1, 5"}
             {:editor    Integer  :constraints "3, 5" :atom field3 :minimum 0}
             {:label     "Label4" :constraints "1, 7"}
             {:editor    Boolean  :constraints "3, 7" :atom field4}
             {:component printer-button :constraints "5, 5"}]
            :colspec   "pref, 4dlu, 50dlu, 4dlu, min"
            :rowspec   "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref"
            :rowgroups [[1 3 5]]
            :border    com.jgoodies.forms.factories.Borders/DIALOG_BORDER))

        (doto (JFrame. "Hello")
          (-> (.getContentPane) (.add panel))
          (.pack)
          (.setVisible true))

More thorough documentation can be found at the moment in the [wiki][] on
the [bitbucket site][bb].

[wiki]: http://bitbucket.org/kotarak/jazz/wiki
[bb]:   http://bitbucket.org/kotarak/jazz

-- 
Meikel Brandmeyer <mb ! kotka ? de>
Frankfurt am Main, 2009