Sunday, May 6, 2012

Create ImageView using JavaFX ImageViewBuilder, load image from internet.

Create ImageView using ImageViewBuilder



package javafximage;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.GroupBuilder;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.ImageViewBuilder;
import javafx.stage.Stage;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaFXImage extends Application {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
    
    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("java-buddy.blogspot.com");
        Group root = new Group();
                
        String imageSource = "http://goo.gl/kYEQl";
        
        ImageView imageView = ImageViewBuilder.create()
                .image(new Image(imageSource))
                .build();
        
        Group myGroup = GroupBuilder.create()
                .children(imageView)
                .build();
        
        root.getChildren().add(myGroup);
  
        primaryStage.setScene(new Scene(root, 500, 400));
        primaryStage.show();
    }
}


No comments:

Post a Comment