Dynamic Component, Preview Problem [message #1755927] |
Thu, 09 March 2017 10:53 |
Phil Kan Messages: 4 Registered: March 2017 |
Junior Member |
|
|
Hello Guys,
my Name is Philipp i'm 24 years and from Germany. At the Moment I have a little Problem with the JavaFX Preview Feature in my Project.
To create a custom control I use the "dynamic component" attribute from the FXGraph, which works perfectly at my running Application. But when I use the JavaFX Preview feature, the custom control will be rendered twice. The first time with an active controller (even when I hadn't select the "load controller" button) and than without the controller.
Like I said, it makes no problem at the running Application but it is really annoying when you work at the fxgraph file. Because the preview always loads my controller, it could happen that the fxgraph file did not response for several seconds, because the controller fills his elements with data at the initialize method.
So I want to ask what I can do about this:
- The Controller always loads and not only when I pressed the "Load Controller"
- The Preview loads the own custom control twice.
Maybe it's just my stupid way how I use the dynamic component function. So here is a simple code example
The java Class which should represent the custom control, where I can store my variables and load the FXGraph.
public class BasicButtonView extends VBox {
public BasicButtonView() throws IOException {
super();
FXMLLoader loader = new FXMLLoader(this.getClass().getResource("/basic/button/BasicButtonView.fxml"));
loader.setRoot(this);
loader.load();
}
}
My FXGraph File, which has the BasicButtonView (which is a VBox) as root
dynamic component BasicButtonView controlledby BasicButtonController {
BasicButtonView {
Button id btnBasic {
text : "Hello World"
}
}
}
My Controller which will be loaded everytime :/
public class BasicButtonController implements Initializable {
@FXML
Button btnBasic;
@Override
public void initialize(URL location, ResourceBundle resources) {
//Normally some magic, that can take several seconds
btnBasic.setText("Goodbye World");
}
}
The Preview
(Im Not sure if this "Insert image into message body" works that way :/ Its attachment "Preview")
The way I use it from an other FXGraph file
dynamic component BasicCheckboxView controlledby BasicCheckboxController {
BasicCheckboxView id rootNode {
top : BasicButtonView,
left : Label{
text : "Magic"
}
}
}
The Preview from the other FXGraph
(Im Not sure if this "Insert image into message body" works that way :/ Its attachment "Preview2")
The way I use it in my Application
@Override
public void start(Stage primaryStage) throws Exception {
Scene scene = new Scene(new BasicButtonView());
primaryStage.setScene(scene);
primaryStage.show();
}
I hope some of you can solve my problem. Thank you in anticipation!
Greetings
Philipp
-
Attachment: Preview.PNG
(Size: 8.98KB, Downloaded 578 times) -
Attachment: Preview2.PNG
(Size: 7.58KB, Downloaded 546 times)
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05007 seconds