PROGRAMMING

 
REMEMBERS




Main

The controller that calls Gui's main() method - HelloApp class
 
/**
 * HelloApp class ...
 * Calls Gui main() method 
 */

package com.minte9.javafx.first_app;

public class HelloApp {
    public static void main(String[] args) {
        HelloGui.main(args);
    }
}
... 5 lines
 

Launch

The GUI class that launches the application - HelloGui class
 
/**
 * Gui launcher class ...
 * Loads and display hello.xml file generated with Scene Builder
 */

package com.minte9.javafx.first_app;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class HelloGui extends Application {

    public static void main(String[] args) {
        launch(args);
    }
    
    @Override public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("hello.fxml"));

        stage.setTitle("Hello World");
        stage.setScene(new Scene(root, 300, 300));
        stage.show();
    }
}
... 16 lines
 

Fxml

Fxml file hello.fxml generated with Scene Builder.
 
<?xml version="1.0" encoding="UTF-8"?>
<!-- // hello.fxml -->

<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<VBox 
    alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" 
    minHeight="-Infinity" minWidth="-Infinity" 
    prefHeight="400.0" prefWidth="600.0" 
    xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">

    <children>
        <Label text="Hello World">
            <font>
                <Font size="18.0" />
            </font>
        </Label>
    </children>
</VBox>
... 13 lines
 

Questions     github JavaFX
Jar Archive

        A B C D E F
🔔
1/1