Created
November 13, 2020 21:17
-
-
Save wuiler/8387fc6b367eb666b33ff822f1b433fe to your computer and use it in GitHub Desktop.
JavaFX Image Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.scene.Group; | |
import javafx.scene.Scene; | |
import javafx.scene.image.Image; | |
import javafx.scene.image.ImageView; | |
import javafx.stage.Stage; | |
public class ImageExample extends Application { | |
@Override | |
public void start(Stage stage) throws java.io.FileNotFoundException { | |
Image image = new Image(new java.io.FileInputStream("javanetar.jpg")); | |
ImageView imageView = new ImageView(image); | |
Group root = new Group(imageView); | |
Scene scene = new Scene(root, 600, 500); | |
stage.setTitle("Welcome to www.java.net.ar !"); | |
stage.setMaximized(true); | |
stage.setScene(scene); | |
stage.show(); | |
} | |
public static void main(String args[]) { | |
launch(args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This use JavaFX 11. See https://openjfx.io/ for more info:
You need to set JAVAFX, JAVAFX_MODS, JAVA_HOME and change the path where your java environment is. For example:
export JAVAFX=/opt/openjfx-11.0.2_linux-x64_bin-sdk/javafx-sdk-11.0.2/lib/
export JAVAFX_MODS=/opt/openjfx-11.0.2_linux-x64_bin-jmods/javafx-jmods-11.0.2/
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
To compile:
/usr/lib/jvm/java-11-openjdk-amd64/bin/java --module-path $JAVAFX_MODS --add-modules javafx.controls ImageExample
To run:
/usr/lib/jvm/java-11-openjdk-amd64/bin/java --module-path $JAVAFX --add-modules javafx.controls ImageExample