com.github.athi.athifx.gui.application.LoadingScreen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of athi-fx-gui Show documentation
Show all versions of athi-fx-gui Show documentation
AthiFX project for creating JavaFX simple application GUI.
The newest version!
package com.github.athi.athifx.gui.application;
import com.github.athi.athifx.gui.font_awesome.FontAwesome;
import javafx.application.Platform;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import static com.github.athi.athifx.gui.configuration.ApplicationConfiguration.LOADING_APPLICATION_MESSAGE;
/**
* Created by Athi
*/
class LoadingScreen extends AbstractScreen {
private Stage loadingStage;
private Label errorLabel;
void show() {
loadingStage = new Stage();
loadingStage.initStyle(StageStyle.UNDECORATED);
AnchorPane root = prepareRoot(loadingStage);
root.setPrefWidth(400);
root.setPrefHeight(40);
ProgressBar progressBar = new ProgressBar();
Label infoLabel = new Label(LOADING_APPLICATION_MESSAGE);
errorLabel = new Label();
Button button = new Button();
button.setStyle("-fx-background-color: transparent;");
button.setGraphic(FontAwesome.labelIcon(FontAwesome.CLOSE_ALIAS, 26));
button.setOnAction(event -> Platform.exit());
root.getChildren().addAll(progressBar, infoLabel, errorLabel, button);
setAnchors(progressBar, 2.0, 2.0, 2.0, 2.0);
setAnchors(infoLabel, 8.0, 2.0, 22.0, 22.0);
setAnchors(errorLabel, 8.0, 32.0, 22.0, 2.0);
setAnchors(button, 396.0, 2.0, 2.0, 22.0);
loadingStage.show();
}
void close() {
if (loadingStage.isShowing()) {
loadingStage.close();
}
}
void setError(String error) {
errorLabel.setText(error);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy