0 Replies Latest reply: Dec 27, 2012 2:32 PM by 981943 RSS

    Calling view method in controller

      I want invoke view method in controller but I don't know how :) I sought like example, but I don't found it. Can I do that in this code ? whether I must build it anew ? I use javafx and fxml technology( to build user interface ).

      My view file ( it have gotoRegister() and gotoLogin() method ( i want to invoke them ))
      public class FXMLExampleMVC extends Application{
          protected Parent root;
          public void start(Stage stage) throws Exception {
              Scene scene = new Scene(root);
              stage.setTitle("JavaFX Welcome!");
          public void gotoRegister() throws IOException{
              root = FXMLLoader.load(getClass().getResource("RegisterFXML.fxml"));  
          public void gotoLogin() throws IOException{
              root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
          public static void main(String[] args) {
      My controller ( here i want invoke gotoRegister() method )
      public class SampleController {
          public SampleModel model = new SampleModel();
          protected Text actiontarget;
          protected PasswordField passwordField;
          protected TextField loginField;
          @FXML protected void handleSubmitButtonAction(){
              if((loginField.getText().equals(model.returnLogin()))&&(passwordField.getText().equals(model.returnPass())) ){
                  actiontarget.setText("You have access !");
              } else {
                 actiontarget.setText("Wrong data !"); 
          @FXML protected void handleSubmitButtonRegister() throws IOException{
             //Here I want to invoke gotoRegister
      My question: Can I invoke gotoRegister ? or, maybe is other way to change fxml file ( from controller )?

      Edited by: 978940 on 2012-12-27 12:32