Skip to content

Instantly share code, notes, and snippets.

@dfletcher
Last active December 3, 2018 23:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dfletcher/441295a027b8c983192f to your computer and use it in GitHub Desktop.
Save dfletcher/441295a027b8c983192f to your computer and use it in GitHub Desktop.
JavaFX Clojure app template
(ns myapp.core (:gen-class))
(gen-class
:name myapp.Application
:extends javafx.application.Application
:prefix "myapp-")
(defn ^:Private myapp-start
"Implements javafx.application.Application.start."
[app ^javafx.stage.Stage stage]
(let [ args (into-array String (-> app .getParameters .getRaw))
] ; TODO Create a Scene or load one from fxml.
; args is now a similar seq as was passed to -main originally.
; Do all program init in here.
(doto stage
(.setTitle "Hi I'm a window.")
;(.setScene scene)
(.show))))
(defn -main
"Program launcher."
[& args]
(javafx.application.Application/launch myapp.Application (into-array String args)))
(ns myapp.dev
(:require [myapp.core :refer [-main]]))
(defn dev-start
[& args]
(.start (Thread. (fn [] (apply -main args)))))
(dev-start "--arg1" "--arg2" "blah")
(defproject myapp "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.6.0"]]
:main myapp.core
:aot [myapp.core]) ; Need this to generate our Application class.
@dfletcher
Copy link
Author

Note that gist doesn't allow subdirectories so move core.clj and dev.clj into the appropriate source directory before building.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment