Since defining the UI in Clojure is pretty tedious process, even with all nice interop features, I decided to write a small library to do this more easily and in a declarative way. I was inspired by a series of blogposts by Stuart Sierra, he wrote a wonderful macro that deals with GridBagLayout. But often you don't need that complex layout, any simpler layout will do. So I spent an evening writing this https://github.com/alexander-yakushev/deflayout . Currently only BorderLayout and FlowLayout are supported, but layouts can be added easily. I wanted somebody to look at the code and give the opinion about what can be done better and what changes can be made. Usage of the lib is very easy. Here is an example from my tetris game:
(deflayout frame (:border) :WEST gamepanel :EAST (deflayout sidepanel (:flow :TRAILING) nextpanel (JButton. "Exit"))) In this example we define, that the frame will use BorderLayout and add two panels - one on the west side, and second one on the east one. Sidepanel that we add is the macro call itself, with FlowLayout and two elements added - another panel and a button. As you see, the macro executes the code differently based on which layout is used. Thus, when the BorderLayout is used, arguments are read by pairs where the first argument is position and the second is the object. Instead, in FlowLayout all objects are just passed sequentially. I will surely extend this macro to cover all other layouts, but I need some of the guidance and recommendations. Also, I would be happy if Stuart Sierra allowed me to include his GridBagLayout code into the lib. -- 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