package bluej;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.control.ProgressBar;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration;
| This class implements a splash window that can be displayed while BlueJ is
| starting up.
|
| @author Michael Kolling
|
public class SplashWindow
extends Stage{
| Construct a splash window.
| @param image
|
public SplashWindow(Image image)
{
super(StageStyle.TRANSPARENT);
ImageView imageView = new ImageView(image);
BorderPane borderPane = new BorderPane(imageView);
borderPane.setBackground(null);
ProgressBar progress = new ProgressBar();
progress.setMaxWidth(Double.MAX_VALUE);
borderPane.setBottom(progress);
progress.setVisible(false);
Scene scene = new Scene(borderPane);
scene.setFill(null);
setScene(scene);
Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
setX((screenBounds.getWidth() - image.getWidth()) / 2);
setY((screenBounds.getHeight() - image.getHeight()) / 2);
setOnShown(e -> {
toFront();
});
show();
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(5000), e -> {
if (isShowing()) {
progress.setVisible(true);
}
}));
timeline.setCycleCount(1);
timeline.play();
}
}
top,
use,
map,
class SplashWindow
. SplashWindow
57 neLoCode
+ 5 LoComm