Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aaronc/fx-clj
A Clojure library for JavaFX
https://github.com/aaronc/fx-clj
Last synced: about 2 months ago
JSON representation
A Clojure library for JavaFX
- Host: GitHub
- URL: https://github.com/aaronc/fx-clj
- Owner: aaronc
- License: epl-1.0
- Created: 2014-09-08T03:40:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-05-22T09:59:37.000Z (over 6 years ago)
- Last Synced: 2024-10-14T21:58:26.490Z (2 months ago)
- Language: Clojure
- Homepage: http://documentup.com/aaronc/fx-clj
- Size: 474 KB
- Stars: 108
- Watchers: 12
- Forks: 9
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-clojure - fx-clj
README
**[Guide](http://documentup.com/aaronc/fx-clj)** | **[API docs](http://aaronc.github.io/fx-clj/)** | **[Source](http://github.com/aaronc/fx-clj)** | **[CHANGELOG](https://github.com/aaronc/fx-clj/releases)** | **[License](https://raw.githubusercontent.com/aaronc/fx-clj/master/LICENSE)**
[![Clojars Project](http://clojars.org/fx-clj/latest-version.svg)](http://clojars.org/fx-clj)
Beta quality - the API is pretty stable and has gotten a fair amount of testing. JDK 8 and at least Clojure 1.7.0-alpha3 are required.
## Overview
A Clojure library for JavaFX 8 with the following goals:
- Provide convenience functions for creating and modifying JavaFX
objects without attempting to completely hide the JavaFX API
- Work with **core.async** out of the box
- Provide support for creating JavaFX objects with both a function
based - `(fx/h-box (fx/button "Hello World"))` - and **hiccup-like** API -
`(fx/compile-fx [:h-box [:button "Hello World"]])`.
- Provide an API for modifying nodes with selectors (sort of like enlive) **for interacting with
FXML resources**
- Allow for setting JavaFX CSS from code and integrate with the **garden CSS**
library
- Helper functions for **i18n**
- Provide **data binding to reactive atoms, cursors and expressions** (via [freactive.core](https://github.com/aaronc/freactive.core)).## Quick Start
Make sure you have installed [JDK 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) and have lein configured to use it. See the leiningen [sample.project.clj](https://github.com/technomancy/leiningen/blob/master/sample.project.clj) and search for `LEIN_JAVA_CMD`, `:java-cmd` and `JAVA_CMD` to see different ways to do this.
Add the leiningen dependency to your project listed above and a namespace declaration similar to the following to your code:
```clojure
(ns my-ns
(:require [fx-clj.core :as fx]))
```A "hello world" example:
```clojure
(ns example
(:require [fx-clj.core :as fx]))(defn create-view []
(fx/h-box
(fx/button {:on-action (fn [e] (println "Hello World!"))
:text "Click Me!"})))(fx/sandbox #'create-view) ;; Creates a "sandbox" JavaFX window to
;; show the view. Clicking F5 in this
;; window will refresh the view allowing the
;; create-view function to be updated at the REPL```
A quick example for integrating `fx-clj` and `core.async`:
```clojure
(ns example2
(:require [fx-clj.core :as fx])
(:require [clojure.core.async :refer [chan go !]]))(defn create-view []
(let [click-ch (chan)
btn (fx/button :#my-btn {:on-action click-ch ;; You can bind a core.async channel directly to an event
:text "Next"})txt (fx/text "Initial text")
view (fx/v-box txt btn)]
(go
(