Javafx启动动画的修改

Javafx启动动画的修改

  1. 创建类继承SplashScreen,重载getImagePath()方法,修改成自定义GIF图
public class BootView extends SplashScreen {
    
    

    @Override
    public String getImagePath() {
    
    
        return "/image/dongtai.gif";
    }
}
  1. 修改springboot启动类方法
public class CommissioningProjectApplication extends AbstractJavaFxApplicationSupport {
    
    
    public static void main(String[] args) {
    
    
        launch(CommissioningProjectApplication.class, LayoutView.class,new BootView(), args);
    }

  1. 取消启动动画下方进度条,重载getParent方法
import de.felixroske.jfxsupport.SplashScreen;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.ProgressBar;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;

public class BootView extends SplashScreen {
    
    


    @Override
    public Parent getParent() {
    
    
        ImageView imageView = new ImageView(this.getClass().getResource(this.getImagePath()).toExternalForm());
        VBox vbox = new VBox();
        vbox.getChildren().addAll(new Node[]{
    
    imageView});
        return vbox;
    }
    @Override
    public boolean visible() {
    
    
        return super.visible();
    }
    @Override
    public String getImagePath() {
    
    
        return "/image/dongtai.gif";
    }
}
  1. 如果需要关闭启动动画,只需要重载visible方法,返回false即可
public class BootView extends SplashScreen {
    
    
    @Override
    public boolean visible() {
    
    
        return false;
    }
}

猜你喜欢

转载自blog.csdn.net/qq_42900469/article/details/130292862