Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9042949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:37:40+00:00 2026-06-16T10:37:40+00:00

I want invoke view method in controller but I don’t know how :) I

  • 0

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;
    @Override
    public void start(Stage stage) throws Exception {
        gotoLogin();

        Scene scene = new Scene(root);

        stage.setScene(scene);
        stage.setTitle("JavaFX Welcome!");
        scene.getStylesheets().add(FXMLExampleMVC.class.getResource("cssforapp.css").toExternalForm());

        stage.show();
    }

    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) {
      launch(args);  
    }
}

My controller ( here i want invoke gotoRegister() method )

public class SampleController {

    public SampleModel model = new SampleModel();
    @FXML
    protected Text actiontarget;
    @FXML
    protected PasswordField passwordField;
    @FXML
    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 )?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:37:41+00:00Added an answer on June 16, 2026 at 10:37 am

    put this code in FXMLExampleMVC.java

    private static FXMLExampleMVC instance;
    public FXMLExampleMVC() {
               instance = this;
    }
    // static method to get instance of view
    public static FXMLExampleMVC getInstance() {
            return instance;
    }
    

    and now you can call your view methods in controller like this

      @FXML protected void handleSubmitButtonRegister() throws IOException{
            // 
           //Here I want to invoke gotoRegister
            FXMLExampleMVC.getInstance().gotoRegister();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to invoke a selector of a method that has the usual NSError**
Does anyone know how can i invoke a method on the click of the
Given a storyboard-based application, how can any one view controller invoke the methods of
I want to invoke the method by the method name stored in the list.
I want to invoke the main method which is static. I got the object
I have a button that when i tap on it i want to invoke
This is my javascript method in .aspx file. I want to invoke this method
I've an IBAction that calls up a panel. I want to invoke that action
I have a WCF application that is using NetTcpBinding . I want to invoke
I want to specifically invoke the base class method; what's the most concise way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.