List of usage examples for javafx.scene.image ImageView ImageView
public ImageView(Image image)
From source file:Main.java
/** * Creates an image canvas with the given width and height. *//*from w w w . jav a 2s .c om*/ public static Canvas createImageCanvas(String url, double width, double height) { ImageView img = new ImageView(new Image(url, width, height, false, true)); final Canvas canvas = new Canvas(width, height); final GraphicsContext gc = canvas.getGraphicsContext2D(); gc.drawImage(img.getImage(), 0, 0); return canvas; }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setWidth(300);/*from w ww.j av a 2s. c o m*/ stage.setHeight(150); Button button = new Button("Hover Over Me"); Tooltip toolTip = new Tooltip("Tooltip for Button"); Node icon = new ImageView(new Image(getClass().getResourceAsStream("root.png"))); toolTip.setGraphic(icon); button.setTooltip(toolTip); ((Group) scene.getRoot()).getChildren().add(button); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { String imagePath = "resources/picture/yourImage.jpg"; Image image = new Image(imagePath); ImageView imageView = new ImageView(image); Button saveBtn = new Button("Save Image"); VBox root = new VBox(10, imageView, saveBtn); Scene scene = new Scene(root); stage.setScene(scene);/*from w w w .ja va 2s.c o m*/ stage.setTitle(""); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { String imagePath = "resources/picture/yourImage.jpg"; Image image = new Image(imagePath); ImageView imageView = new ImageView(image); Button saveBtn = new Button("Save Image"); saveBtn.setOnAction(e -> saveToFile(image)); VBox root = new VBox(10, imageView, saveBtn); Scene scene = new Scene(root); stage.setScene(scene);/*from w ww . j a v a2 s . co m*/ stage.setTitle(""); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);/*from w ww .j a v a 2s .co m*/ stage.setHeight(180); HBox hbox = new HBox(); Image image = new Image(getClass().getResourceAsStream("labels.jpg")); Label label1 = new Label("Search", new ImageView(image)); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);/*w ww.j a va 2 s. com*/ stage.setHeight(180); HBox hbox = new HBox(); Image image = new Image(getClass().getResourceAsStream("labels.jpg")); Label label1 = new Label("Search", new ImageView(image)); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); label1.setLabelFor(hbox); System.out.println(label1.labelForProperty()); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);/*from w w w .j a v a2s. co m*/ stage.setHeight(180); HBox hbox = new HBox(); Image image = new Image(getClass().getResourceAsStream("labels.jpg")); Label label1 = new Label("Search", new ImageView(image)); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); label1.setLabelFor(hbox); System.out.println(label1.getLabelFor()); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);/*from ww w . ja v a 2s. c o m*/ stage.setHeight(180); HBox hbox = new HBox(); Image image = new Image(getClass().getResourceAsStream("labels.jpg")); Label label1 = new Label("Search", new ImageView(image)); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); label1.setLabelFor(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);//w w w . ja v a2s. c o m stage.setHeight(180); HBox hbox = new HBox(); Image image = new Image(getClass().getResourceAsStream("labels.jpg")); Label label1 = new Label("Search"); label1.setGraphic(new ImageView(image)); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { stage.setTitle("HTML"); stage.setWidth(500);/* www . j av a 2 s. co m*/ stage.setHeight(500); Scene scene = new Scene(new Group()); VBox root = new VBox(); Hyperlink hpl = new Hyperlink("java2s.com"); Image image1 = new Image(new File("a.jpg").toURI().toString(), 0, 100, false, false); hpl.setFont(Font.font("Arial", 14)); hpl.setGraphic(new ImageView(image1)); root.getChildren().addAll(hpl); scene.setRoot(root); stage.setScene(scene); stage.show(); }