title: JavaFx Controller set Object Another Controller
body: <p>I'am gettin Admin object in LoginController. Its not null there is no problem. When i setting this object AdminController its not working. In my initialize syso result showing "null".  I need to use this object in my other controller. Using swing i was doing this in controller constructors and swing construtors. But i dont know how i can do that with JavaFx. Sorry for my bad english. But if u look code, u will understand me.</p>
  
  <pre><code>    public class UserLoginController extends AbstractController {
  
      @FXML
      private Button joinBtn;
      @FXML
      private Button exitBtn;
      @FXML
      private Label statusLabel;
      @FXML
      private TextField userNo;
      @FXML
      private PasswordField password;
  
  
      @FXML
      void buttonEvent(ActionEvent event) {
  
          if (joinBtn == event.getSource()) {
              String userType = userNo.getText().substring(0, 2);
              switch (userType) {
              case "10":
                  Admin admin = DBContext.getInstance().admins().isUserExist(Integer.parseInt(userNo.getText()), password.getText());
                  if(admin != null) {
                      final String fxml = "/educationManagement/view/AdminPanel.fxml";
                      try {
                          FXMLLoader loader = new FXMLLoader(getClass().getResource(fxml));
                          Parent root = (Parent) loader.load();
                          AdminController adminController = loader.getController();
                          adminController.setAdmin(admin);
                          Scene scene = new Scene(root);
                          Stage stage = (Stage) ((Node)event.getSource()).getScene().getWindow();
                          stage.setTitle(admin.getFirstName() + " " + admin.getLastName());
                          stage.setScene(scene);
                          stage.show();
                      } catch (Exception e) {
                          e.printStackTrace();
                          System.out.println("fuck");
                      }
  
                  } else {
                      statusLabel.setText("Kullanıcı Adı veya Şifre Yanlış");
                      userNo.setText("");
                      password.setText("");
                  }
                  break;
  
              case "40":
  
                  break;
  
              case "50":
  
                  break;
  
              default:
                  statusLabel.setText("Kullanıcı Adı Bulunamadı");
                  break;
              }
  
          }
      }
  }
  
  
  public class AdminController implements Initializable{
  
      private Admin admin;
  
      @FXML
      private TableView&lt;Student&gt; studentTable;
  
      @FXML
      private Label firstNameLbl;
  
      public Admin getAdmin() {
          return admin;
      }
  
      public void setAdmin(Admin admin) {
          this.admin = admin;
      }
  
      @Override
      public void initialize(URL location, ResourceBundle resources) {
          System.out.println(admin);
  
      }
  
  }
  </code></pre>