I've just started trying to create a UI with Clojure using Swing. But I am getting a CompilerException when trying to load it. I have been following this tutorial 'https://stuartsierra.com/2010/01/02/swing-into-actions-with-clojure'.
I am using IntelliJ IDEA Community with Cursive, using Leiningen and Clojure 1.8 and I'm on Linux Mint 19.1 (if that even matters).
My code:
(defn say-hello []
(JOptionPane/showMessageDialog
nil "Hello, World!" "Greeting" JOptionPane/INFORMATION_MESSAGE))
(def act (proxy [ActionListener] []
(actionPerformed [event] (say-hello))))
(def button (doto (JButton. "Click Me!")
(.addActionListener act)))
(def panel (doto (JPanel.)
(.add button)))
(def frame (doto (JFrame. "Hello Frame")
(.setSize 800 800)
(.setContentPane panel)
(.setVisible true)))
(def frame (doto (JFrame. "SportSeer")
(.setSize 800 800)
(.setVisible true)))
When ran through nREPL I get:
Loading src/sportseer_client/core.clj...
CompilerException java.lang.NoClassDefFoundError: Could not initialize class javax.swing.RepaintManager, compiling:(core.clj:12:13)
Edit: Also, when I restart the REPL and load the file for the first time I get this error:
Loading src/sportseer_client/core.clj...
CompilerException java.awt.AWTError: Assistive Technology not found: org.GNOME.Accessibility.AtkWrapper, compiling:(core.clj:12:13)
Somehow I have had this example work when messing about within the repl alone, and then afterwards being able to load from a file without any problems. No idea what I done differently except for using the other import function:
(import '(javax.swing JOptionPan JButton JFrame JPanel))
but I can no longer replicate this and get this to work.
Any help in pointing me in the right direction to fix this will be greatly appreciated.