7

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?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
CN1002
  • 1,115
  • 3
  • 20
  • 40

1 Answers1

13

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.

Mauricio Gracia Gutierrez
  • 10,288
  • 6
  • 68
  • 99
dic19
  • 17,821
  • 6
  • 40
  • 69