4

So I have a regular component extending from BorderPane and I want to add it into some FXML code. I am getting java.lang.IllegalArgumentException: Unable to coerce SettingsTab to class javafx.scene.Node. SettingsTab extends BorderPane:

public class SettingsTab extends BorderPane { ...

I am trying to include it like this:

<Tab fx:id="settingsTab" text="%ui.gui.settings.title" content="SettingsTab"/>

The FXML code and the class are in the same package/directory.

I am relatively new to FXML and not very familiar with the syntax, so I am not sure how to do this.

I can include FXML files like this, but I want to include a class file:

 <Tab fx:id="scheduleTab" text="%ui.gui.schedule.title">
      <fx:include source="ScheduleTab.fxml"/>
 </Tab>
Chris Smith
  • 2,928
  • 4
  • 27
  • 59

1 Answers1

2

The Tab needs a content tag like this and not as an attribute value.

<TabPane>
  <Tab fx:id="settingsTab" text="%ui.gui.settings.title">
    <content>
      <BorderPane></BorderPane>
    </content>
  </Tab>
</TabPane>

And in your case:

<TabPane>
  <Tab fx:id="settingsTab" text="%ui.gui.settings.title">
    <content>
      <SettingsTab></SettingsTab>
    </content>
  </Tab>
</TabPane>

And you need an import in your fxml for your custom component:

<?import my.custom.package.SettingsTab ?>
aw-think
  • 4,723
  • 2
  • 21
  • 42