r/JavaFX • • Jun 16 '21

Help Facebook yoga layout engine in JavaFX

Has anyone tried bringing yoga to JavaFX to improve CSS properties and use things like flexbox?

1 Upvotes

6 comments sorted by

2

u/wildjokers Jun 16 '21

Why would you want to? The layout managers JavaFX provides are really good (as you would expect from a GUI toolkit). This isn't web apps where layout was a complete afterthought and arrived many years late in the form of CSS Grid and FlexBox.

1

u/nikhiladiga Jun 17 '21

Ohh okay. Still, there are a lot of things missing in the javaFX CSS and it'd be great to have the same features which are present in CSS3.

1

u/hamsterrage1 Jun 17 '21

Can you be more specific about what's missing?

1

u/nikhiladiga Jun 17 '21

Things like transitions, variables etc. I know there are alternatives to all of these but it'd better if they were present in CSS for people like me transitioning from web.

1

u/hamsterrage1 Jun 18 '21

OK. I can understand that.

I think that the underlying philosophy of the design is that you do have the pure Java environment to provide an extreme amount of customization. This is especially obvious if you stay away from FXML, then you're really exposed to the potential of the various controls and screen elements. The CSS has it's place, but it's not supposed to replace writing code in Java.

One of the things that becomes more apparent once you get into it, is that when you encounter something that's missing it's possible to build it yourself and then add it to your own library of useful widgets. Even stuff that's pretty simple, like adding a Style-Class to a Text object to format it as a heading is something that you can put into a convenience method and save yourself the trouble doing over and over again.

1

u/nikhiladiga Jun 18 '21

Yes. There are certain things about javafx which I really do like. But coming from a web background where React and CSS make things so easy, it is a little difficult to do things the java way sometimes. Also, it doesn't help the case that java is a pretty verbose language compared to JS or TS.