I am doing some development in Clojure (a Lisp type language for the JVM). Lisp as in a clone tailored for the JVM, not Lisp as only “functional programming”. I note, by the way, that more than functional programming, Lisp is an homoiconic language.
I developed a simple system to specify Swing menus in clojure, here is an example:

Simple Menu
The following “micro-language” was developed to specify this:
(getMenuBar actionManager '( (menu { :text "Project" :key "P" :content ( (item {:text "New" :key "N"}) (item {:text "Open" :key "O" }) (item {:text "Close" :key "O" :id "Close" :enabled false}) (item {:text "Recent" :key "R"}) (separator) (item {:text "Exit" :key "E"}) ) }) (menu { :text "Options" :key "O" :content ( (item {:text "Rendering" :key "R"}) ) }) ))
The code is very easy to read, I hope: two menu items, with a few menu entries with text, ability to enable/disable and accelerator keys, plus a separator.
Notice the actionManager on top, is it the (very simple) event processing function which receives only a text as parameter (to identify the selection). The text is simply the menu text, or, if specified an id. Not the most general solution, but enough for simple menu structures.
The code? Below is the _complete_ implementation.
(ns org.tiago.swing ;(:require clojure.contrib.def) (:use [clojure.contrib.seq-utils :only (flatten)] [clojure.contrib.def :only (defnk)] ) (:import (java.awt.event ActionListener KeyEvent) (javax.swing JFrame JMenu JMenuBar JMenuItem) ) ) (defnk createFrame [title :menuBar nil] (def frame (new JFrame title)) (. frame setDefaultCloseOperation (. JFrame EXIT_ON_CLOSE)) (if menuBar (. frame setJMenuBar menuBar)) (. frame pack) (. frame setVisible true) frame ) (defmulti addMItem (fn [manager x & rst] (first x))) (defmethod addMItem 'item [manager content menu] (let [params (second content)] (def mItem (new JMenuItem (:text params))) (if (contains? params :id) (. mItem putClientProperty "id" (:id params))) (if (contains? params :key) (. mItem setMnemonic (. (:key params) charAt 0))) (. menu add mItem) (. mItem addActionListener manager) ) ) (defmethod addMItem 'separator [manager sep menu] (. menu addSeparator) ) (defmulti getMBItem first) (defmethod getMBItem 'menu [desc] (let [params (second desc) manager (last desc)] (def menu (new JMenu (:text params))) ;Assuming mnemonic is ASCII CODE. ;java7 has . KeyEvent getExtendedKeyCodeForChar (if (contains? params :key) (. menu setMnemonic (. (:key params) charAt 0))) (if (contains? params :id) (. menu putClientProperty "id" (:id params))) (dorun (map #(addMItem manager % menu) (:content params))) menu ) ) (defmethod getMBItem :default [arg] (new JMenu "UNK")) (defn getMenuBar [actionManager menuItems] (let [manager ( proxy [ActionListener] [] (actionPerformed [e] (let [obj (.getSource e) id (.getClientProperty obj "id")] (actionManager (if (nil? id) (. obj getText) id)) )) )] (def menuBar (new JMenuBar)) (dorun (map #(. menuBar add %) (map #(getMBItem (concat % (cons manager ()))) menuItems))) menuBar ) )
OK, comments have to be added
.
From a declarative point of view, not bad at all.
My first Lisp program. It completely baffles me that, 25 years of programming with all the languages imaginable (including some functional like Caml or highly declarative like Prolog), I never tried Lisp.