Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

launch(args) in main

Carig just says that the launch method is called with args as parameters. I wanted to know where and when ? does the START() method is called as thats where our nodes and scene graphics resides.

public class Main extends Application {

@Override
public void start(Stage primaryStage) throws Exception{
   // Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
    Group root = new Group();
    Text txt = new Text("Sup?");
    root.getChildren().add(txt);
    txt.setY(50);
    primaryStage.setTitle("Sup");
    primaryStage.setScene(new Scene(root, 300, 275));
    primaryStage.show();
}


public static void main(String[] args) {
    launch(args);
}

}

Can you link to the video?

1 Answer

By using 'extends Application' you are inheriting the Application.java class. In that class, you call launch() and it will eventually call the start() method.

Many times in programming you will not know why something works, just that it does work by doing XYZ. Assume the XYZ in this case is calling launch(args) and creating a start method.

Thanks Philip. I did debugging and went to explore...."LauncherImpl" class that eventually calls the START() method....thanks again..