public class ImageShapeDemo extends Application
1: import javafx.application.Application;
2: import javafx.scene.Scene;
3: import javafx.stage.Stage;
4: import javafx.scene.layout.VBox;
5: import javafx.scene.image.Image;
6: import javafx.scene.image.ImageView;
7: import javafx.scene.shape.Circle;
8: import javafx.scene.shape.Rectangle;
9: import javafx.scene.paint.Color;
10:
11: /**
12: Demonstration of some shapes and an image
13: within a VBox layout.
14: */
15: public class ImageShapeDemo extends Application
16: {
17: public static void main(String[] args)
18: {
19: launch(args);
20: }
21:
22: @Override
23: public void start(Stage primaryStage) throws Exception
24: {
25: VBox root = new VBox();
26: ImageView imv = new ImageView();
27: // Java looks for "java.jpg" in the default folder
28: Image img = new Image("java.jpg");
29: imv.setImage(img);
30:
31: Circle c = new Circle();
32: c.setRadius(25);
33: c.setFill(Color.PINK);
34:
35: Rectangle r = new Rectangle();
36: r.setWidth(100);
37: r.setHeight(50);
38: r.setFill(Color.BLUE);
39:
40: root.getChildren().add(imv);
41: root.getChildren().add(c);
42: root.getChildren().add(r);
43:
44:
45: Scene scene = new Scene(root, 300, 200);
46: primaryStage.setTitle("Image and Shape Demo");
47: primaryStage.setScene(scene);
48: primaryStage.show();
49: }
50: }