What’s the best way to organize JavaFX 2.0 code

code-organizationjavafx

In every example I have seen yet almost all of the GUI code is written in the start(Stage stage) method of the main class. Is this the best approach, or is it OK to subclass the Stage class and make your own thing? If the latter is OK, wouldn't the performance suffer because of lot of Stages?

Best Answer

You have to use stage given to start method as your main Stage because it's created for you by JavaFX startup logic (and it can be desktop stage, jnlp one, or a plugin in the browser so you better not create it yourself). If you need another windows in your application (dialogs, warning, popup windows, etc) you can create new Stages. You can use them as new Stage() objects or subclass, at doesn't really matter or affect performance (IMHO).

Related Topic