Answer the question
In order to leave comments, you need to log in
Where is the best place to write the main method in JavaFX?
There are Oracal tutorials .
There are simple examples in which the application is built like this:
public class ColorfulCircles extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
// код GUI
primaryStage.show();
}
}
import javafx.application.Application;
public class Main {
public static void main(String[] args) {
Application.launch(TaskManagerApp.class, args);
}
}
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class TaskManagerApp extends Application {
@Override
public void start(Stage primaryStage) {
Scene scene = new Scene(new Label("Hello world"), 420, 500);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Answer the question
In order to leave comments, you need to log in
It's bad to use derogatory names, especially when the uncle gives good advice, yu know. The author on SO means that you need to separate the concepts of entry point and application. That is, there must be an entry point, and there must be an application. Separately. The advantage of this approach is that the SRP is better respected, and the application can also be used in other "cleaner" entry points: whether it's Android or GWT (but it depends on the coolness of understanding and implementing OOP), or ordinary unit tests. The Application class can be considered a facade in terms of design patterns. JavaFX has nothing to do with it.
----
Notes in the margins
In textbooks, they try to write as simple a code as possible to make it easier to understand and reinforce the material. Therefore, main(String... args) occurs almost everywhere in such cases.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question