I am learning JavaFX. I have encountered a problem; I cannot figure out what is the equivalent of a Swing JFrame in JavaFX. Is it the Scene or the Stage?
Advertisement
Answer
The equivalent of a Swing JFrame
in JavaFX is the Stage class which extends from Window and can be made visible by calling show() method. The Scene is more like the frame’s content pane (not exactly the same but similar in concept).
Off-topic
For details on components similar to JDialog
have a read to this Marco Jakob’s post: JavaFX Dialogs (official)
On the other hand there are third-party options available such as ControlsFX and Marco Jakob’s JavaFX dialogs, or we can play with stage’s Modality to achieve something close as exemplified here.