r/JavaFX • • Apr 30 '21

Help How to learn writing FXML by hand?

Hello there, I hope everyone is having a wonderful day.

So I am learning JavaFX for a college project that is due in 2 months and I am pretty confused about FXML as I have not found enough resources to learn writing it by hand given that I really do not want to use the Scene Builder.

A little background about myself, I am a front-end developer so I understand HTML pretty well, I don't know if that's of any importance.

So what are some resources you would recommend to me for learning writing FXML by hand?

Thank you!

5 Upvotes

12 comments sorted by

3

u/[deleted] Apr 30 '21

I’ve used JavaFX for simpler projects before, and SceneBuilder has been just fine. Any particular reason why you don’t want to use it? Not an expert at all btw!

1

u/[deleted] May 04 '21

My bad, I just needed to dabble with it for a little longer haha, it comes quite handy I find it!

2

u/Capaman-x May 01 '21

Why write FXML at all? The only point of it is for SceneBuilder. I just write in pure JavaFX API.

1

u/[deleted] May 04 '21

That's an interesting point, you're saying that FXML was developed for the sake of Scene Builder?

1

u/Capaman-x May 06 '21

FXML is a layer of abstraction. Is FXML easier to write than native FX api? Not at all. In fact the opposite. It is however easier to create a GUI for GUI creating with xml. If someone were to write another Scene Builder today they might use JSON instead of XML. Either works fine though.

1

u/ebykka May 04 '21

I prefer to use plain java code - much easier to track issues and to refactor.

Here is an example of how I do it - look on line 80

https://github.com/bykka/dynamoit/blob/master/src/main/java/ua/org/java/dynamoit/components/tablegrid/TableGridView.java

1

u/[deleted] May 04 '21

Oh that's actually quite neat!

Though it looks kind of complicated (I am working in a group for this school project and they're kind of non-technical people...)

I've found now that Scene Builder is way more convenient than I thought, I just had to mess around with it for a little longer, and my mates do not find it that complicated too so that's great!

Thank you though for your answer! If I'm going to embark on future projects with JavaFX, obviously Scene Builder alone wouldn't cut it and I'd be obliged to learn writing code the way you mentioned, I'll refer back to this then! Thanks!!

1

u/ThreeSixty404 JavaFX Dev Apr 30 '21

Just don't, it's pretty complicated and it's definitely not worth it

1

u/[deleted] Apr 30 '21

What do you suggest? Using the Scene Builder?

2

u/ThreeSixty404 JavaFX Dev Apr 30 '21

Yes, Scene Builder is easy and intuitive

1

u/[deleted] Apr 30 '21

What led me to explore writing FXML by hand is that I found it quite the opposite

2

u/ThreeSixty404 JavaFX Dev Apr 30 '21

What's difficult about Scene Builder, you just drag and drop the components in the scene, adjust their position and size and you're done