Commit 03b93af7 authored by Thomas COUCHOUD's avatar Thomas COUCHOUD

jfx verify taskbar before using it

parent f1335185
Pipeline #58392425 passed with stages
in 3 minutes and 25 seconds
......@@ -5,12 +5,12 @@
<parent>
<artifactId>utils</artifactId>
<groupId>fr.mrcraftcod</groupId>
<version>12.0.3</version>
<version>12.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>utils.base</artifactId>
<version>12.0.3</version>
<version>12.0.4</version>
<packaging>jar</packaging>
<dependencies>
......
......@@ -5,12 +5,12 @@
<parent>
<artifactId>utils</artifactId>
<groupId>fr.mrcraftcod</groupId>
<version>12.0.3</version>
<version>12.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>utils.config</artifactId>
<version>12.0.3</version>
<version>12.0.4</version>
<packaging>jar</packaging>
<dependencies>
......
......@@ -5,12 +5,12 @@
<parent>
<artifactId>utils</artifactId>
<groupId>fr.mrcraftcod</groupId>
<version>12.0.3</version>
<version>12.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>utils.http</artifactId>
<version>12.0.3</version>
<version>12.0.4</version>
<packaging>jar</packaging>
<dependencies>
......
......@@ -5,12 +5,12 @@
<parent>
<artifactId>utils</artifactId>
<groupId>fr.mrcraftcod</groupId>
<version>12.0.3</version>
<version>12.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>utils.javafx</artifactId>
<version>12.0.3</version>
<version>12.0.4</version>
<packaging>jar</packaging>
<dependencies>
......
......@@ -6,72 +6,72 @@ import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import java.awt.*;
import java.awt.Taskbar;
import java.util.function.Consumer;
@SuppressWarnings({
"WeakerAccess",
"unused"
})
public abstract class ApplicationBase extends Application
{
public abstract class ApplicationBase extends Application{
private Stage stage;
public void start(Stage stage) throws Exception
{
public void start(Stage stage) throws Exception{
this.stage = stage;
preInit();
Scene scene = buildScene(stage);
stage.setTitle(this.getFrameTitle());
stage.setScene(scene);
stage.sizeToScene();
if(getIcon() != null)
if(getIcon() != null){
setIcon(getIcon());
if(getStageHandler() != null)
}
if(getStageHandler() != null){
this.getStageHandler().accept(stage);
if(shouldDisplayAtStart())
{
}
if(shouldDisplayAtStart()){
stage.show();
if(getOnStageDisplayed() != null)
if(getOnStageDisplayed() != null){
this.getOnStageDisplayed().accept(stage);
}
}
}
private void setIcon(Image icon)
{
private void setIcon(Image icon){
this.stage.getIcons().clear();
this.stage.getIcons().add(icon);
Taskbar.getTaskbar().setIconImage(SwingFXUtils.fromFXImage(icon, null));
if(Taskbar.isTaskbarSupported()){
final var taskbar = Taskbar.getTaskbar();
if(taskbar.isSupported(Taskbar.Feature.ICON_IMAGE)){
taskbar.setIconImage(SwingFXUtils.fromFXImage(icon, null));
}
}
}
@SuppressWarnings("RedundantThrows")
public void preInit() throws Exception{}
public Image getIcon()
{
public Image getIcon(){
return null;
}
public boolean shouldDisplayAtStart()
{
public boolean shouldDisplayAtStart(){
return true;
}
public Scene buildScene(Stage stage)
{
public Scene buildScene(Stage stage){
return new Scene(createContent(stage));
}
public abstract String getFrameTitle();
public abstract Consumer<Stage> getStageHandler();
public abstract Consumer<Stage> getOnStageDisplayed() throws Exception;
public abstract Parent createContent(Stage stage);
public Stage getStage()
{
public Stage getStage(){
return stage;
}
}
......@@ -5,12 +5,12 @@
<parent>
<artifactId>utils</artifactId>
<groupId>fr.mrcraftcod</groupId>
<version>12.0.3</version>
<version>12.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>utils.mail</artifactId>
<version>12.0.3</version>
<version>12.0.4</version>
<packaging>jar</packaging>
<dependencies>
......
......@@ -5,12 +5,12 @@
<parent>
<artifactId>utils</artifactId>
<groupId>fr.mrcraftcod</groupId>
<version>12.0.3</version>
<version>12.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>utils.resources</artifactId>
<version>12.0.3</version>
<version>12.0.4</version>
<packaging>jar</packaging>
<dependencies>
......
......@@ -7,7 +7,7 @@
<groupId>fr.mrcraftcod</groupId>
<artifactId>utils</artifactId>
<packaging>pom</packaging>
<version>12.0.3</version>
<version>12.0.4</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>12</java.version>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment