Skip to content

Instantly share code, notes, and snippets.

@ajchemist
Forked from dfletcher/core.clj
Created September 29, 2016 13:56
Show Gist options
  • Save ajchemist/56ae912a6088fdc48eaa3e9e8bc64bbd to your computer and use it in GitHub Desktop.
Save ajchemist/56ae912a6088fdc48eaa3e9e8bc64bbd 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment