I wish to access value of selected item from the Combobox of one controller class in other controller class.
I am having three values "Easy", "Medium" and "Difficult" in the combobox observablelist of one controller class. Lets say, I select "Easy" option and proceed to other class, then I wish to access its value which is 'Easy' in this case.
I have declared my Combobox in the first class as follows :
public ComboBox combobox = new ComboBox();
In other class, I am writing following code to access its value on a button click :
HomefxmlController hfc = new HomefxmlController();
System.out.println(hfc.combobox.getSelectionModel().getSelectedItem());
It returned NULL
I further tried to access it using a method with return type "String", but got a NullPointerException instead.
Can anyone tell me how to resolve it and access its item value from a completely different class ?
FYI : This has no relation between changing scenes and accessing other FXML controller class, I am having problem on accessing object values.