The starting point for a JavaFX application is the launch method. But in JavaFX application examples, there is also a basic method. What is the use of the main method in this particular case and why did it become necessary to define start () as the starting point for JavaFX. Could we just use a basic method to determine the starting point, such as Swings?
HelloWorld sample application:
public class HelloWorld extends Application { @Override public void start(Stage primaryStage) { Button btn = new Button("Hello World"); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Hello World!"); } }); StackPane root = new StackPane(); root.getChildren().add(btn); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
java
Jeeshu mittal
source share