I wrote some code to enable declarative swing definitions pretty much identical in form to Michael's suggestion:
(let [gui (swingset (JFrame frame {:setSize [500 500]} (JPanel panel {:setBackground (. Color orange)} (JLabel {:setText "Hello World. Welcome to my Swing GUI created from Clojure."}) (JPanel {:setLayout (new BorderLayout)} (JTextArea { :setText "type here and marvel as nothing happens!"})) (JButton btn {:setText "Close"}))) (GridLayout layout {:setColumns 1 :setRows 3}) (JMenuBar menubar (JMenu {:setText "File"} (JMenuItem {:setText "Save" :addActionListener (actionListener (fn [e] (println "Sorry, can't save")))})) (JMenu {:setText "Edit"} (JMenuItem {:setText "Cut" :addActionListener (actionListener (fn [e] (println "You clicked Cut")))}) (JMenuItem {:setText "Paste" :addActionListener (actionListener (fn [e] (println "You clicked Paste")))}))))] (. (gui 'frame) setJMenuBar (gui 'menubar)) (. (gui 'panel) setLayout (gui 'layout)) (. (gui 'frame) setVisible true) (. (gui 'btn) addActionListener (actionListener (fn [e] (. (gui 'frame) setVisible false))))) It works for the simple examples I've tried. It returns a map of selected controls which you might need access to. As Michael mentioned, getting the layout manager to do what you want is difficult. I haven't used Swing before, so maybe this isn't specific to using a declarative style. I can't see a tidy way to let the components refer to each other within the definition which might be handy, and as you can see it's pretty verbose even for simply windows. Some parts could be shortened with some extra macro - menu's in particular, but I'm starting to think UI code is going to look pretty ugly unless you drastically limit the options for customisation - there's just too many widgets with too may variables involved. And I haven't even thought about using the UI once it's been constructed. --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---