FXMLBuilder StackOverflowError [message #1723345] |
Sun, 14 February 2016 16:48  |
Eclipse User |
|
|
|
What is the correct way to load an FXML file in a e4 part?
The builder.load() method generates a StackOverflowError.
I created an e4 Application project from File->New->Project...->JavaFX->OSGI
I edited the @PostConstruct method to look like the following:
@PostConstruct
public void postConstruct(BorderPane parent, @FXMLLoader FXMLLoaderFactory factory) {
try {
FXMLBuilder<Node> builder = factory.loadRequestorRelative("IOS.fxml");
Node n = builder.load();
parent.setCenter(n);
} catch (IOException e) {
e.printStackTrace();
}
// This works when the FXML loader code is commented out.
// Button btn = new Button("Hello World");
// btn.setId("hwButton");
// btn.setOnAction(new EventHandler<ActionEvent>() {
// @Override
// public void handle(ActionEvent event) {
// System.out.println("Button clicked");
// }
// });
// parent.setCenter(btn);
}
The FXML looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Do not edit this file it is generated by e(fx)clipse from ../src/com/parts/IOS.fxgraph
-->
<?import java.lang.*?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.BorderPane?>
<?scenebuilder-stylesheet /css/default.css?>
<BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="com.parts.UIPart">
<center>
<Button fx:id="hwButton" text="Hello World" onAction="#clicked"/>
</center>
</BorderPane>
Thanks for the help,
John
[Updated on: Sun, 14 February 2016 16:50] by Moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04175 seconds