Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bjagg/clojure-minimal-javafx
Clojure code implementing a very simple JavaFX Application.
https://github.com/bjagg/clojure-minimal-javafx
clojure javafx javafx-application minimal
Last synced: about 2 months ago
JSON representation
Clojure code implementing a very simple JavaFX Application.
- Host: GitHub
- URL: https://github.com/bjagg/clojure-minimal-javafx
- Owner: bjagg
- License: epl-1.0
- Created: 2018-02-08T19:00:05.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T05:29:48.000Z (about 1 year ago)
- Last Synced: 2024-10-12T20:30:06.061Z (3 months ago)
- Topics: clojure, javafx, javafx-application, minimal
- Language: Clojure
- Size: 6.84 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# clojure-minimal-javafx
A Clojure application that implements the very short program
defined in the JavaDocs for [`javafx.application.Application`][1]:```
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;public class MyApp extends Application {
public void start(Stage stage) {
Circle circ = new Circle(40, 40, 30);
Group root = new Group(circ);
Scene scene = new Scene(root, 400, 300);stage.setTitle("My JavaFX Application");
stage.setScene(scene);
stage.show();
}
}
```### Code Notes
- The addition of `:main` and `:aot` to `project.clj` is required due
to the self-reference in the `-main` function.
- The Java code uses a variadic argument constructor for `javafx.scene.Group`.
In Clojure, it is challenging to invoke this constructor. Instead, the
no-argument constructor is used, and the circle is added post-creation.
- The generated Application class needs to be passed to `launch()` as functions
are inner classes in Java. Also, hyphens in namespaces are converted
to underscores for packages and files.## Usage
```
lein run
```## License
Copyright © 2018 Benito Gonzalez
Distributed under the Eclipse Public License.
[1]: https://docs.oracle.com/javase/8/javafx/api/javafx/application/Application.html