Last active
December 3, 2018 23:08
-
-
Save dfletcher/441295a027b8c983192f to your computer and use it in GitHub Desktop.
JavaFX Clojure app template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns myapp.dev | |
(:require [myapp.core :refer [-main]])) | |
(defn dev-start | |
[& args] | |
(.start (Thread. (fn [] (apply -main args))))) | |
(dev-start "--arg1" "--arg2" "blah") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that gist doesn't allow subdirectories so move core.clj and dev.clj into the appropriate source directory before building.