Skip to content

Clojure code implementing a very simple JavaFX Application.

License

Notifications You must be signed in to change notification settings

bjagg/clojure-minimal-javafx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clojure-minimal-javafx

A Clojure application that implements the very short program defined in the JavaDocs for javafx.application.Application:

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.

About

Clojure code implementing a very simple JavaFX Application.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published