Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFx equivalent of Swing JFrame

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?

like image 317
CN1002 Avatar asked Jan 16 '15 12:01

CN1002


People also ask

Does JavaFX replace Swing?

JavaFX was intended to replace Swing as the standard GUI library for Java SE, but it has been dropped from new Standard Editions while Swing and AWT remain included, supposedly because JavaFX's marketshare has been "eroded by the rise of 'mobile first' and 'web first applications." With the release of JDK 11 in 2018, ...

Is JavaFX same as Swing?

In short, Swing and JavaFX are both GUI toolkits for Java programs. Swing is the old standard toolkit that features a bigger library of GUI elements and mature IDE support. JavaFX is the newer standard with a smaller library, more consistent updates, and consistent MVC support.

Is JavaFX based on Swing?

JavaFX has UI Components but still evolving. It also has several components built over the Swing. Swing is the legacy library for GUI. JavaFX can help to create rich internet applications with modern UI.

Is JavaFX easier than Swing?

JavaFX makes it easier to form desktop applications and games in Java. JavaFX has replaced Swing because of the suggested GUI toolkit for Java.


1 Answers

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.

like image 71
dic19 Avatar answered Sep 19 '22 15:09

dic19