Take a look at the imports in mainController.java
:
They don’t contain an import for javafx.scene.text.TextFlow
and textflow.TextFlow
is used instead. You need to add an import to javafx.scene.text.TextFlow
. In addition consider renaming your TextFlow
class. Using the same type names as types in the API you use can easily lead to confusion.
When mainController
‘s constructor is executed the fxml file is handled until FXMLLoader
tries to inject the javafx.scene.text.TextFlow
instance to the tofl
field which results in a IOException
because of the mismatched types.
Since you’re simply ignoring the exception in the catch
clause instead of handling it, the constructor completes normally and the partially loaded node is added to your scene. It’s usually better to at least print the exception, unless you know the exception won’t cause (or indicate) an issue, since this makes debugging much easier.
0
solved Adding TextFlow to FXML controller makes GUI blank