Skip to Main Content

Java User Groups

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Importing a JavaFX library using JavaScript

John PAug 8 2024

I would like to know more about how I can import a JavaFX library while using JavaScript.

This is for trying to use a JavaScript applet on my mobile devices, while importing and using a JavaFX Form container and its controls.

Here's what I have done so far:

Here I have written this code snippet in Microsoft Notepad.

I have successfully compiled and run it using Java at the Windows command prompt.

What I want to know now is how would I import a JavaFX library using JavaScript.

All users are welcome to add some files using the .js format extension.

javac --module-path C:\Users\john2\Downloads\openjfx-22.0.2_windows-x64_bin-sdk\javafx-sdk-22.0.2\lib --add-modules javafx.controls,javafx.fxml HelloWorldFX.java
java --module-path C:\Users\john2\Downloads\openjfx-22.0.2_windows-x64_bin-sdk\javafx-sdk-22.0.2\lib --add-modules javafx.controls,javafx.fxml HelloWorldFX
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class HelloWorldFX extends Application {

    @Override
    public void start(Stage stage) {
        String javaVersion = System.getProperty("java.version");
        String javafxVersion = System.getProperty("javafx.version");
        Label l = new Label("Hello World running on JavaFX " + javafxVersion + " on top of Java " + javaVersion + ".");
        Scene scene = new Scene(new StackPane(l), 640, 480);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }

}
Comments
Post Details
Added on Aug 8 2024
0 comments
387 views