Comments (6)
Yes, I agree. Good thing to have!
from springboot-javafx-support.
Nice, thanks
from springboot-javafx-support.
Thank you for the recommendation. We have make some changes for the functionality. Its now working.
Usage:
** Main.java
launchApp(Main.class, HelloworldView.class, args, true);
** AbstractJavaFxApplicationSupport.java
private static boolean savedHasPreloader;
@Override
public void start(Stage stage) throws Exception {
if(savedHasPreloader) {
notifyPreloader(new Preloader.StateChangeNotification(
Preloader.StateChangeNotification.Type.BEFORE_START));
stage.toFront();
}
String stageStyle = applicationContext.getEnvironment().getProperty("javafx.stage.style");
// User requests a different StageStyle?
// Then we need a new one:
if(stageStyle != null) {
StageStyle style = StageStyle.valueOf(stageStyle.toUpperCase());
stage = new Stage(style);
}
AbstractJavaFxApplicationSupport.stage = stage;
showView(savedInitialView);
}
protected static void launchApp(Class<? extends AbstractJavaFxApplicationSupport> appClass,
Class<? extends AbstractFxmlView> view, String[] args, boolean hasPreloader) {
savedInitialView = view;
savedArgs = args;
savedHasPreloader = hasPreloader;
if(savedHasPreloader)
LauncherImpl.launchApplication(appClass, Splash.class, args);
else
Application.launch(appClass, args);
}
** Splash.java
import javafx.animation.FadeTransition;
import javafx.application.Preloader;
import javafx.geometry.Pos;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration;
/**
* @author Ajesh - Inspired by https://gist.github.com/jewelsea/1588531
*/
public class Splash extends Preloader {
private Stage stage;
private Pane splashLayout;
private ProgressBar loadProgress;
private Label progressText;
public static final String SPLASH_IMAGE = "http://fxexperience.com/wp-content/uploads/2010/06/logo.png";
private static final int SPLASH_WIDTH = 676;
private static final int SPLASH_HEIGHT = 227;
@Override public void init() {
ImageView splash = new ImageView(new Image(SPLASH_IMAGE));
loadProgress = new ProgressBar();
loadProgress.setPrefWidth(SPLASH_WIDTH - 20);
progressText = new Label("Loading STODA-fx 1.0 . . . . .");
splashLayout = new VBox();
splashLayout.getChildren().addAll(splash, loadProgress, progressText);
progressText.setAlignment(Pos.CENTER);
splashLayout.setStyle("-fx-padding: 5; -fx-background-color: cornsilk; -fx-border-width:5; -fx-border-color: linear-gradient(to bottom, chocolate, derive(chocolate, 50%));");
splashLayout.setEffect(new DropShadow());
}
@Override public void start(final Stage initStage) throws Exception {
Scene splashScene = new Scene(splashLayout);
initStage.initStyle(StageStyle.UNDECORATED);
final Rectangle2D bounds = Screen.getPrimary().getBounds();
initStage.setScene(splashScene);
initStage.setX(bounds.getMinX() + bounds.getWidth() / 2 - SPLASH_WIDTH / 2);
initStage.setY(bounds.getMinY() + bounds.getHeight() / 2 - SPLASH_HEIGHT / 2);
initStage.show();
this.stage = initStage;
}
@Override
public void handleApplicationNotification(Preloader.PreloaderNotification notification) {
if (notification instanceof StateChangeNotification) {
FadeTransition fadeSplash = new FadeTransition(Duration.seconds(0.4), splashLayout);
fadeSplash.setFromValue(1.0);
fadeSplash.setToValue(0.0);
fadeSplash.setOnFinished(actionEvent -> stage.hide());
fadeSplash.play();
}
}
}
Final step under working
Spring environment variables:
javafx.splash.image=logo.png
javafx.splash.text=Spring Loading...
Auto identify splash preferred width and height.
from springboot-javafx-support.
Problem is that we can't use Spring environment at that time because the application context is not up yet.
My first approach is in the branch SplashScreen.
I am thinking of overloading the launchApp method accepting a config class that returns some nodes (getSplashImage , getSplashLoadingIndicator) or something like that as strategies - and maybe providing a default implementation.
from springboot-javafx-support.
Yes sure, we can't identify spring environment properties for setting SplashScreen prerequisites. getSplashLoadingIndicator is interesting! I agree your strategy. Good Luck
from springboot-javafx-support.
Added with 1.3.13.
Shows at least now a standard screen. Needs still more documentation (as everything).
from springboot-javafx-support.
Related Issues (20)
- How to run on different platforms, how to pack?
- How to set the locale for the whole application ? HOT 3
- showView methods from AbstractJavaFxApplicationSupport should return more information HOT 1
- there is a Exception when i use webView in FXML
- Disable web-server
- have any plans to upgrade to javafx11? HOT 2
- How to support Chinese? HOT 2
- How to set the title of dialog or subwindow? HOT 1
- Allow custom error action
- How to close a stage create by Main.showView()? thanks
- Getting No auto configuration classes found when extending AbstractJavaFxApplicationSupport.class with @SpringBootApplication class HOT 6
- Can't set controller in HelloworldJavaView demo HOT 3
- No auto configuration classes found when extending AbstractJavaFxApplicationSupport.class with @SpringBootApplication class on Java 11
- Multiple window problems HOT 2
- How to change the display of the page HOT 1
- Whether it is possible to update java11 branches to maven libraries HOT 1
- it cannot load classpath resource HOT 1
- de.felixroske.jfxsupport.AbstractJavaFxApplicationSupport - Failed to load spring application context: HOT 1
- <Error: No auto configuration classes found in META-INF/spring.factories> HOT 6
- Suggest changing the createStage method from private to public
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from springboot-javafx-support.