import javafx.animation.KeyFrame; import javafx.animation.KeyValue; import javafx.animation.Timeline; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.stage.StageStyle; import javafx.util.Duration; /** * @author Uladzimir Rybau * @since 09.09.11 */ public class OpacityTest extends Application { public static void main( String[] args ) { launch( args ); } public void start( Stage stage ) { stage.setTitle( "Opacity Test" ); stage.setOpacity( 0.1 ); stage.initStyle( StageStyle.TRANSPARENT ); HBox root = new HBox(); Button button = new Button( "Button 1" ); button.setPrefSize( 300, 300 ); root.getChildren().addAll( button, new Button( "Button 2" ), new Button( "Button 3" ) ); Scene scene = new Scene( root, -1, -1, Color.AQUAMARINE ); stage.setScene( scene ); stage.sizeToScene(); Timeline timeline = new Timeline(); timeline.setCycleCount( 1 ); double startOpacity = 0.1; double endOpacity = 1.0; //endOpacity = 0.9; timeline.getKeyFrames().addAll ( new KeyFrame( Duration.ZERO, new KeyValue( stage.opacityProperty(), startOpacity ) ), new KeyFrame( new Duration( 3000 ), new KeyValue( stage.opacityProperty(), endOpacity ) ) ); stage.show(); timeline.play(); } }