Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scene Builder 2.0. FXML import not working

I'm using JavaFX Scene Builder 2.0. version and I would like to import a FXML file under TabPane controller. My idea is that I will have one kind of container FXML file with TabPane and separate FXML files for things that will come inside of tabs. When I try to import FXML file where I have things that I would like to add under one tab, Scene Builder gives error message "Failed to import TabContents.fxml under TabPane". Why it is not possible to import anything under the TabPane? If I import same file directly under root StackPane everything works.

like image 388
user1643694 Avatar asked Oct 18 '25 22:10

user1643694


2 Answers

Three simple steps

  1. Add a StackPane to the content area of your Tab, ensuring that it occupies 100% of the area.
  2. Go to the Hierarchy view and select that StackPane you just added.
  3. Include your TabContents.fxml. It should automatically be added to the created StackPane and should display as desired.

Also, to answer your additional question, importing it directly into the TabPane will render it as a Graphic rather than a Node.

like image 181
alexstewartja Avatar answered Oct 20 '25 13:10

alexstewartja


EDIT: While the below works, it is best to add some sort of layout pane (like an AnchorPane) to each tab in your TabPane, select the AnchorPane pane in the hierarchy view on the left and then import your other fxml document into that, as opposed to importing directly into a TabPane (Perhaps if the root node of the document is a Tab it would work?).


Looks like a bug, for now:

  • Cut your entire document hierarchy
  • Add an empty stack pane
  • Include your other FXML file
  • Paste your document hierarchy into the stack pane
  • Drag your FXML file into the appropriate place in your hierarchy
  • Cut your new hierarchy (with your file included)
  • Delete the now defunct stack pane
  • Paste your hierarchy back in

And voila, working as intended!

like image 29
Troyseph Avatar answered Oct 20 '25 14:10

Troyseph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!