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

  • SEARCH
  • Home
  • 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 8180265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:10:37+00:00 2026-06-07T00:10:37+00:00

I have a very simple fxml file, with a checkbox: … <AnchorPane id=AnchorPane xmlns:fx=http://javafx.com/fxml

  • 0

I have a very simple fxml file, with a checkbox:

...
<AnchorPane id="AnchorPane" xmlns:fx="http://javafx.com/fxml" fx:controller="jfx01.T01">
...
<CheckBox fx:id="checkBox1" text="CheckBox" />
...

the very simple controller class is the following:

public class T01 extends Application {

    @FXML protected CheckBox checkBox1;

    @Override
    public void start(Stage primaryStage) throws IOException {
         Parent root = FXMLLoader.load(getClass().getResource("t01.fxml"));   
         primaryStage.setScene(new Scene(root));
         primaryStage.show();

         //here, here is the problem!
         System.out.println("checkBox1==null? "+ (checkBox1==null?"yes":"no"));

    }
}

The output of this basic app is:

checkBox1==null? yes

Inside the “start” method the components are obviously created, but not yet assigned to @FXML fields of the controller class. As a test that there aren’t other errors, i’ve added a button and an event.
There the checkBox1 IS assigned!

    @FXML protected void handleButton1Action(ActionEvent event) {
        System.out.println("button pressed");
        checkBox1.setSelected(!checkBox1.isSelected());
    }

Question

If I can’t use start method because init is not yet complete, what is the first method available where the init is complete and so the components are available?

  • 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-07T00:10:38+00:00Added an answer on June 7, 2026 at 12:10 am

    The Controller should implement javafx.fxml.Initializable and override initialize(URL arg0, ResourceBundle res) method. The CheckBox checkBox1 will be initialized and be avaliable in that initialize method for you by the FXMLLoader. The convenience way is to separate the Controller and Main (that extends Application) classes, so app starting/entry point and the FXML file controller should be 2 different classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple python script that should scan a text file, which
I have a very simple XML file, that looks like this: <Data><Day Num=4197> <Date>270611</Date>
I have a very simple XML file: <?xml version=1.0 encoding=ISO-8859-1?> <Data><Day Num=4197> <Date>270611</Date> <Energy>47</Energy>
I'm starting with Spring Web MVC. I have very simple controller and view, but
I have very simple OpenGL ES example similar to Hehe's example : http://nehe.gamedev.net/tutorial/ios_lesson_02__first_triangle/50001/ As
In my Rails 3.0.11 app, we have very simple code in a controller: def
I have very simple window where I have 2 buttons - one for cancel,
I have a very simple webforms app that will allow field techs to order
I have some very simple XML: <properties> <property> <name>BobFish</name> <explaination>Bob is a fish.</explaination> </property>
I have a very simple Setup project that copies three dlls into the GAC.

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.