Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explanation of mapping between JavaFX properties and component descriptions #178

Open
rongcuid opened this issue Apr 26, 2024 · 3 comments

Comments

@rongcuid
Copy link

I am struggling to connect the JavaFX API with cljfx's description. From my understanding of the readme, a property x in JavaFX API would map to the description as an :x key in the component description map, but this doesn't seem to be the case. For instance, if I translate a basic demo from JavaFX's documentation (https://docs.oracle.com/javase/8/javafx/scene-graph-tutorial/scenegraph.htm#JFXSG107):

package scenegraphdemo;
 
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
 
public class Main extends Application {
 
   @Override
   public void start(Stage stage) {
       Group root = new Group();
       Scene scene = new Scene(root, 500, 500, Color.BLACK);
       stage.setTitle("JavaFX Scene Graph Demo");
       stage.setScene(scene);
       stage.show();
   }
 
   public static void main(String[] args) {
       launch(args);
   }
}

To what I thought is valid cljfx code:

(fx/on-fx-thread
 (fx/create-component
  {:fx/type :stage
   :title "JavaFX Scene Graph Demo"
   :showing true
   :scene {:fx/type :scene
           :width 500.0 :height 500.0
           :fill :black
           :root {:fx/type :group}}}))

It will not work, because there's no :width or :height properties. I tried to go through the code, but I can't find the definitions.

Is this a special case for Stage? Or is it some other problem?

@vlaaad
Copy link
Contributor

vlaaad commented Apr 26, 2024

Huh, scene has width/height that are settable only in constructor, TIL. You can use width/height props on stage. Also check out https://github.com/cljfx/dev

@rongcuid
Copy link
Author

Ok, I'll check out the dev tool. How does constructor properties map to cljfx in the first place?

@vlaaad
Copy link
Contributor

vlaaad commented Apr 26, 2024

I'm principle, the same way as other properties, e.g. :root is scene's constructor property. I missed scene width and height here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants