Question
Help needed! JavaFX package mouserollover; import static com.sun.glass.events.WindowEvent.MAXIMIZE; import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.Pane; public class MouseRollover extends Application
Help needed!
JavaFX
package mouserollover;
import static com.sun.glass.events.WindowEvent.MAXIMIZE; import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.Pane;
public class MouseRollover extends Application {
public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { final double SCENE_WIDTH = 500.0; final double SCENE_HEIGHT = 500.0; Image balloonImage = new Image("file:HotAirBalloon.jpg"); Image flowerImage = new Image("file:flower.jpg"); ImageView myImageView = new ImageView(flowerImage); myImageView.setFitWidth(200); myImageView.setPreserveRatio(true); myImageView.setOnMouseEntered(event -> { myImageView = new ImageView(balloonImage); }); myImageView.setOnMouseExited(event -> { myImageView = new ImageView(flowerImage); });
Pane pane = new Pane(myImageView);
Scene scene = new Scene(pane, SCENE_WIDTH, SCENE_HEIGHT); primaryStage.setScene(scene); primaryStage.show(); } }
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