I'm trying to create a project just like the seesaw example window-builder, I've created a project called my-gui-project, copied the code from src/window_builder/core.clj and src/window_builder/MyForm.java into my project and and changed line 31 where it says:
(let [form (identify (window_builder.MyForm.))]
into:
(let [form (identify (my_gui_project.MyForm.))].
Then, I ran the following commands: lein deps, lein compile and lein run -m my-gui-project.core and it returns the following error:
Exception in thread "main" java.lang.ClassNotFoundException: my_gui_project.MyForm, compiling:(my_gui_project/core.clj:31:24)
Why is this happening? The code is exactly the same, I've just changed the folder name.
This is the complete code:
core.clj:
(ns my-gui-project.core
(:gen-class)
(:use [seesaw.core])
(:require [seesaw.selector :as selector]))
; This is the interesting part. Note that in MyPanel.java, the widgets we're
; interested in have their name set with setName().
(defn identify
"Given a root widget, find all the named widgets and set their Seesaw :id
so they can play nicely with select and everything."
[root]
(doseq [w (select root [:*])]
(if-let [n (.getName w)]
(selector/id-of! w (keyword n))))
root)
(def states ["CA", "GA", "WA"])
(def defaults
{ :first-name "Laura"
:last-name "Palmer"
:street "123 Main St."
:city "Twin Peaks"
:zip "12345"
:state "WA" })
; A helper to create an instance of the form, annotate it for Seesaw and do
; some other initialization.
(defn my-form
[]
(let [form (identify (my_gui_project.MyForm.))]
; initialize the state combobox
(config! (select form [:#state]) :model states)
form))
; Now we just create the panel, initialize it to the defaults above with
; seesaw.core/value! and show it in a dialog. Note how, besides setting the
; names of the widgets, the code in MyForm.java is strictly for layout. All
; behavior, etc is done in Clojure.
(defn -main [& args]
(invoke-later
(let [form (value! (my-form) defaults)
result (-> (dialog :content form :option-type :ok-cancel) pack! show!)]
(if (= :success result)
(println "User entered: " (value form))
(println "User canceled")))))
project.clj:
(defproject my-gui-project "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[seesaw "LATEST"]]
:main ^:skip-aot my-gui-project.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
you likely also need to rename the window_builder directory to match the change in name. and change the package names in any java files.
this is in keeping with the project naming pattern in Clojure of directory_name/namespace.clj with -'s switched to _'s