cr0mbly
cr0mbly

Reputation: 51

making javafx application fade over a period

i need to create a java notification that once show fades over time and then is destroyed, but if the user mouses over it it should become alive. I essentially need to set the transparency of the entire notification (background, labels and image views) over a period to fully transparent. I've searched the web and can't find a straightforward way to do it in javafx any help?

Upvotes: 0

Views: 91

Answers (1)

Deepanshu J bedi
Deepanshu J bedi

Reputation: 1530

Read about transition here.

Example on how to achieve fading here:

 final Rectangle rect1 = new Rectangle(10, 10, 100, 100);
 rect1.setArcHeight(20);
 rect1.setArcWidth(20);
 rect1.setFill(Color.RED);
 ...
 FadeTransition ft = new FadeTransition(Duration.millis(3000), rect1);
 ft.setFromValue(1.0);
 ft.setToValue(0.1);
 ft.setCycleCount(Timeline.INDEFINITE);
 ft.setAutoReverse(true);
 ft.play();

Upvotes: 1

Related Questions