Wednesday, September 2, 2015

JavaFX example: Label with image

JavaFX example to create Label with ImageView.

package javafx_imagelabel;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

 * @web
public class JavaFX_ImageLabel extends Application {
    public void start(Stage primaryStage) {
        //Create Label with ImageView
        Label imageLabel = new Label(
                new ImageView(new Image("")));

        //Create Label, then add graphic to it
        Label imageLabel = new Label("");
        imageLabel.setGraphic(new ImageView(new Image("")));

        StackPane root = new StackPane();
        Scene scene = new Scene(root, 300, 250);
        primaryStage.setTitle("Hello World!");

    public static void main(String[] args) {

No comments:

Post a Comment