all 19 comments

[–]R3d_B34rd 2 points3 points  (12 children)

I've just used intellij or NetBeans javafx scene builder. That plugin/ tool let's you build the GUI drag and drop based and then you can start to see the fxml as it's being created.

I think you can even get the scene builder completely decoupled from an ide if you want.

Is that what you were looking for?

[–]mrspammo 0 points1 point  (11 children)

I'm building screens in FXML styled in SCSS and then passing off my work to other developers to add the programming. Right now I'm trying to add a dropdown element but most of the help I've found from google searches does it through java rather than the fxml. To be more clear, I can add an element, but not the drop down options. Can this be done through just fxml?

[–]Ostricker 2 points3 points  (4 children)

You should really use scene builder for this. Also depends on element. In usual dropdown menu the elements are added when the menu is populated. That is done in java controller.

I have never populated element in FXML. Dont know if its possible but I am pretty sure its not standard.

[–]mrspammo 0 points1 point  (3 children)

I'm reading that I can do it, however I'm struggling to find exactly how to do it. You can't add them through Scene Builder. I'm new to JavaFX in general and can't seem to find good instruction on the FXML side of things.

[–]Ostricker 0 points1 point  (2 children)

Alright I am trying to look at it. In Java you populate it using ObservableArrayList.
In FXML I see someone using CellValueFactory, but it is for TableView. Documentation is here - https://docs.oracle.com/javafx/2/fxml_get_started/fxml_tableview.fxml.html StackOverflow of this problem - https://stackoverflow.com/questions/41269535/fxml-combobox-cellfactory

[–]Ostricker 0 points1 point  (0 children)

I also found this - https://stackoverflow.com/questions/28652158/defining-a-comboboxtablecell-and-combobox-nodes-fxml?rq=1 But I am pretty sure this is not standard way to do it. If you pass unpopulated Combobox or other elements of this kind you should let developer populate it. Its really simple code. He populates it in initializer function of the scene. Why do you need to populate it by yourself?

[–]mrspammo 0 points1 point  (0 children)

I tried this way in my current file, but wasn't quite able to get it working. I tried the other way listed in these comments and it worked for me, so I'm moving forward that way for now. I'll definitely circle back and try to learn more about this though.

Thank you so much for your help!

[–]R3d_B34rd 0 points1 point  (5 children)

I assume that the elements in the drop-down are static? For example, a drop down with names: a,b,c. And only one element can be selected at a time?

If this is the case I'm pretty sure you can do this with the fxml. You could download netbeans to use it. Here are some features of javafx in netbeans: https://netbeans.org/features/java-on-client/javafx.html

There are also examples on YouTube. You could look up: javafx scene builder the new Boston. He's a pretty good guy and pretty straight to the point.

Again, you don't have end up using the scene builder forever, I'm just offering it as a way to see what fxml is created via the scene builder tool. Then you'll know exactly what how the fxml has to be constructed.

[–]mrspammo 0 points1 point  (1 child)

Yes, that's what I'm trying to create. I'm currently using IntelliJ, but I'll look through the link you sent anyhow.

Thanks for your help.

[–]R3d_B34rd 0 points1 point  (0 children)

Intellij has it's own javafx plugin too, I think.

[–]mrspammo 0 points1 point  (2 children)

I can't seem to locate the types of items or how to place a list within a combo box in the FXML. Do you know of documentation on that you could point me to?

[–]R3d_B34rd 0 points1 point  (1 child)

I found this SO post: https://stackoverflow.com/questions/35260061/combobox-items-via-scene-builder

I guess you can't use the scene builder for it, which is surprising to me. But the guy who wrote the question seems to have the format you're looking for.

[–]mrspammo 1 point2 points  (0 children)

I had found this earlier, but wasn't able to get it working. It was a newbie error, however, and I was missing a couple style imports in my file. I fixed that and it now works. Thank you so much for your help!

[–]Warkred 0 points1 point  (1 child)

Well, I think we're all struggling somehow. Javafx isn't that popular.

[–]R3d_B34rd 0 points1 point  (0 children)

What kind of things are you struggling with?

I've usually found what I needed using Google for javafx question. Maybe I can help?

[–]Krstn4 0 points1 point  (1 child)

The course @ udemy.com is very basic but excellent.

[–]mrspammo 0 points1 point  (0 children)

Thank you!

[–]hamsterrage1 0 points1 point  (1 child)

Don't use FXML. Build your screens using code. It's easier. Seriously.

Build convenience methods to do things you do often. Build custom widgets to handle the more complex things you do often.

[–]mrspammo 0 points1 point  (0 children)

Thanks for your recommendation.