Question
FIX THE CODE. How to add URL (http://www.cs.armstrong.edu/liang/image/us.gif ) to this code to display the image us.gif? import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane;
FIX THE CODE. How to add URL (http://www.cs.armstrong.edu/liang/image/us.gif ) to this code to display the image us.gif?
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.geometry.Insets; import javafx.stage.Stage; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import java.net.URL;
public class ShowImage extends Application { @Override // Override the start method in the Application class public void start(Stage primaryStage){ // Create a pane to hold the image views Pane pane = new HBox(10); pane.setPadding(new Insets(5, 5, 5, 5)); Image image = new Image("image/us.gif"); pane.getChildren().add(new ImageView(image)); ImageView imageView2 = new ImageView(image); imageView2.setFitHeight(100); imageView2.setFitWidth(100); pane.getChildren().add(imageView2);
ImageView imageView3 = new ImageView(image); imageView3.setRotate(90); pane.getChildren().add(imageView3); // Create a scene and place it in the stage Scene scene = new Scene(pane); primaryStage.setTitle("ShowImage"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage } /** * The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line. * @param args */ public static void main(String[] args) { launch(args); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started