Before getting upset about the name, I would like to make it clear that I'm better versed in the JavaFX interface. I have been a developer for 9 years using Swing, and currently I decided to try JavaFX. Examples on the net show that JavaFX can indeed create beautiful graphical interfaces compared to Swing. Maybe I'm trying to create and deploy GUIs incorrectly, but one thing is for sure. JavaFX panels load slower than Swing and consume a lot more memory. The same GUI was redesigned using JAVAFX, and it takes up almost 200 MB, and the Swing GUI takes up only 50 MB.
Here I will give a code example of how I create a GUI programmatically using FXML.
public class PanelCreator { private FXMLPane<LoginPaneController> loginFXML; private FXMLPane<RegistrationPaneController> registerFXML; private FXMLPane<EmailValidationPaneController> emailValidationFXML; public PanelCreator() { this.rootPane = rootPane; try { loginFXML = new FXMLPane<LoginPaneController>("Login.fxml"); registerFXML = new FXMLPane<RegistrationPaneController>("Register.fxml"); emailValidationFXML = new FXMLPane<EmailValidationPaneController>("EmailValidation.fxml"); } catch (IOException e) {e.printStackTrace();}
The PanelCreator constructor method creates 3 FXMLPane classes, a class that combines both the FXML panel and its controller. The code for the FXMLPane class is shown in the following code.
public class FXMLPane<T> { private Pane pane; private T paneController; public FXMLPane(String url) throws IOException { URL location = getClass().getResource(url); FXMLLoader fxmlLoader = new FXMLLoader(); fxmlLoader.setLocation(location); fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory()); pane = fxmlLoader.load(location.openStream()); paneController = fxmlLoader.<T>getController(); }
Through PanelCreator, I can now use get methods to get each JavaFX panel and its controller, and I don’t need to run the FXML load method every time to get the panel. My current concern is not that creating FXML GUIs is slower than Swing, but moreover, the RAM is 3 times and 4 times larger than the corresponding version of Swing.
Can someone explain to me what I'm doing wrong? FXML files have only basic components in the Grid panel, such as buttons, layers, and text fields.

The code for the above example can be found here.
performance user-interface memory javafx javafx-8
javasuns
source share