But a JavaFX window needs to be started within its own class extending Application and cannot be instantiated several times.
This statement is wrong, there are restrictions on when you can invoke the constructor on the Window
class, but they are not related to extending the Application
class.
Why can a JavaFX window not be instanciated like other classes?
The constructor of the Window
class is protected, so it can be "used only within the package and in sub-classes outside the package".
Instead, in your application, instantiate a class which is a sub-class of Window
. The appropriate class to use is Stage
. The constructors of Stage
are public rather than protected like Window
.
So, to show two stages (which are windows), you can write:
Stage stage1 = new Stage();
stage1.show();
Stage stage2 = new Stage();
stage2.show();
Why is it called Application and not Window or Frame?
An application is called Application because that what it represents. Within an application, you might have multiple Stages (which are instances of Windows), so it would not make sense to call an Application a Window. Anyway, an Application has a different purpose: It's main purpose is to implement the Application lifecycle interface and processing as described in the Application javadoc.
Why does JavaFX breaks OOP?
It doesn't. It uses a protected modifier on Window to enforce encapsulation, which is a key hiding technique of OOP. It provides subclasses of Windows via inheritance for different purposes such as Stages, which are your standard application windows, and PopupWindows, which are specialized window subsets helping with tasks such as creation of popup lists for context menus and combo boxes. It implements Separation of Concerns by differentiating between Application
and Window
functionality within separate class structures.
Your other questions and statements make no sense to me.