What is the best way to do GUIs in Clojure?
Is there an example of some functional Swing or SWT wrapper? Or some integration with JavaFX declarative GUI description
So I didn't see Fn-Fx on this list, from Timothy Baldridge (halgiri). This is a Clojure library providing a functional abstraction over JavaFX.
It can be found on Github at https://github.com/halgari/fn-fx.
To use, make sure you are using a recent version of Java (1.8 90+) and add a dependency to the github repo by adding the following to your project.clj:
:plugins [[lein-git-deps "0.0.1-SNAPSHOT"]]
:git-dependencies [["https://github.com/halgari/fn-fx.git"]]
I have tried it, and it works out of the box.
Here is another very basic swing wrapping example:
; time for some swing
(import '(javax.swing JFrame JTable JScrollPane))
(import '(javax.swing.table DefaultTableModel))
(let
[frame (JFrame. "Hello Swing")
dm (DefaultTableModel.)
table (JTable. dm)
scroll (JScrollPane. table)]
(doto dm
(.setNumRows 30)
(.setColumnCount 5))
(.. frame getContentPane (add scroll))
(doto frame
(.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
(.pack)
(.setVisible true)))
Clojure and SWT is the best approach for doing GUI(s). Essentially, SWT is a plug and play style approach for developing software.
I know that you are hinting for classical desktop solutions, but web fits quite well with clojure. I've written a complete audio application where everything is hooked up so that if you add music to the audio folder it is reflected in the web UI. Just saying that Desktop application isn't the only way :)