fxmlloader

How to pass parameters to a controller's constructor when using `<fx:include>`?

て烟熏妆下的殇ゞ 提交于 2021-01-28 17:52:01
问题 I am learning JavaFX, and I have come across an issue involving the instantiation of controllers that I can not seem to solve. Essentially, I am wondering if it is possible to do one of the following: Pass a parameter to the constructor of the controller when including FXML with <fx:include> ; or Specify a custom controller instance to use when including an FXML file with <fx:include> . Note that these issues are related. In fact, the reason I am asking about option (2) is because it would

How can I get a reference to the controller of an FXML?

对着背影说爱祢 提交于 2021-01-28 09:08:05
问题 I'm trying to make a small "Login then Main Menu" form using JavaFX and Gluon's Scene Builder. I've made 2 scenes so far, the first one is a "Login" screen in which I've connected a SQLite Database, after putting the right Username and Password it loads perfectly fine and it changes to the second scene. For each scene I use a different class (FXML / FXML Controller). In the second scene I want 2 labels that I use to change according to the Database's data (More specifically First_Name and

JavaFX Load Exception

白昼怎懂夜的黑 提交于 2020-01-25 04:26:32
问题 I'm trying to make a basic calculator application with JavaFX but I'm having trouble launching the application. This is the error I get Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java

FXMLLoader cannot find running controller instance and creates new one

佐手、 提交于 2020-01-16 07:07:52
问题 I'm a newcomer when it comes to JavaFX and I recently encountered a problem which really confuses me alot. I'm using a class called "MainController" which controlls an FXML-File containing a TabPane. Each tab is controlled by another controller. But there is one situation in which a tab needs to be deleted, so I need access to the MainController instance to remove the currently active tab from the pane. Whenever I'm using this code to get an instance of the currently running MainController, I

fxml loader exception “root value is already specified” I never specified a root value

女生的网名这么多〃 提交于 2019-12-24 19:50:18
问题 I am trying to have a hyperlink open a new window. I have copied the fxml loader method from other parts of my code that work without issue. For some reason I am getting an fxml loader exception issue that says the root value is already specified. I have not specified a root value anywhere in my code. I also have not specified a controller in the fxml because other answers on stackoverflow said this might be causing the issue. this is the class that is loading the new Window. the issue occurs

JavaFX FXMLLoader getController NullPointerException

限于喜欢 提交于 2019-12-24 09:47:36
问题 I have a project in school where I have to develop a program where you first can choose whether you want to save/read to/from a SQL DB or to save/read to/from XML. I've made a GUI where you can choose between both methods. The GUI closes after the user clicks on one of the buttons and the MainMenu GUI opens. Now I need to know in the MainMenuController what the user choose. I found online a Method to call the MainMenuController inside the first controller, with FXMLLoader.getController() .

JavaFX FXMLLoader getController NullPointerException

你说的曾经没有我的故事 提交于 2019-12-24 09:45:05
问题 I have a project in school where I have to develop a program where you first can choose whether you want to save/read to/from a SQL DB or to save/read to/from XML. I've made a GUI where you can choose between both methods. The GUI closes after the user clicks on one of the buttons and the MainMenu GUI opens. Now I need to know in the MainMenuController what the user choose. I found online a Method to call the MainMenuController inside the first controller, with FXMLLoader.getController() .

FXMLLoader get controller returns null

给你一囗甜甜゛ 提交于 2019-12-24 02:25:10
问题 I have a recursive case of FXML loading needed here. If I choose to View an Objective, it takes me to another instance of the screen that loads a list of Strategy objects. If I choose to view a Strategy, it takes me to another instance of the screen that loads a list of Tactic objects. If I view a Tactic, it takes me to another instance of the screen that loads a list of Task objects. Naturally, I decided to use a base controller class, ViewChildItemController to handle inheritance. Then I

JavaFX 8 - Tabpanes and tabs with separate FXML and controllers for each tab

删除回忆录丶 提交于 2019-12-20 19:41:07
问题 I hope to get some answers regarding having fx:include statements for each tab in a tabpane. I have managed with ease to get content to show up BUT referencing methods of the associated controller class simply gives me a nullpointerreference exception no matter how I structure it. The controllers of the included FXML layouts do not have neither constructor not initialize() methods, are they needed? I tried some different things but always got the same exception. What I simply did was add a

JavaFX 8 - Tabpanes and tabs with separate FXML and controllers for each tab

陌路散爱 提交于 2019-12-20 19:40:35
问题 I hope to get some answers regarding having fx:include statements for each tab in a tabpane. I have managed with ease to get content to show up BUT referencing methods of the associated controller class simply gives me a nullpointerreference exception no matter how I structure it. The controllers of the included FXML layouts do not have neither constructor not initialize() methods, are they needed? I tried some different things but always got the same exception. What I simply did was add a