Merge pull request #1719 from DSheirer/1619-java-fx-windows-open-minimized

#1619 JavaFX Windows Show Minimized
This commit is contained in:
Denny Sheirer
2023-11-10 05:34:09 -05:00
committed by GitHub
2 changed files with 22 additions and 28 deletions

View File

@@ -164,27 +164,7 @@ public class JavaFxWindowManager extends Application
public void shutdown() public void shutdown()
{ {
MyEventBus.getGlobalEventBus().unregister(this); MyEventBus.getGlobalEventBus().unregister(this);
mUserPreferences.getJavaFxPreferences().clearStageMonitors();
if(mChannelMapStage != null)
{
mUserPreferences.getJavaFxPreferences().unmonitor(mChannelMapStage);
}
if(mIconManagerStage != null)
{
mUserPreferences.getJavaFxPreferences().unmonitor(mIconManagerStage);
}
if(mPlaylistStage != null)
{
mUserPreferences.getJavaFxPreferences().unmonitor(mPlaylistStage);
}
if(mUserPreferencesStage != null)
{
mUserPreferences.getJavaFxPreferences().unmonitor(mUserPreferencesStage);
}
Platform.exit(); Platform.exit();
} }

View File

@@ -1,6 +1,6 @@
/* /*
* ***************************************************************************** * *****************************************************************************
* Copyright (C) 2014-2020 Dennis Sheirer * Copyright (C) 2014-2023 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -20,6 +20,10 @@
package io.github.dsheirer.preference.javafx; package io.github.dsheirer.preference.javafx;
import io.github.dsheirer.preference.decoder.JmbeLibraryPreference; import io.github.dsheirer.preference.decoder.JmbeLibraryPreference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.prefs.Preferences;
import javafx.beans.value.ChangeListener; import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
@@ -28,11 +32,6 @@ import javafx.stage.Stage;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.prefs.Preferences;
/** /**
* Manages user preferences for JavaFX elements (e.g. stages). * Manages user preferences for JavaFX elements (e.g. stages).
*/ */
@@ -59,7 +58,7 @@ public class JavaFxPreferences
*/ */
public void monitor(Stage stage, String key) public void monitor(Stage stage, String key)
{ {
mStageMonitors.remove(new StageMonitor(stage, key)); mStageMonitors.add(new StageMonitor(stage, key));
} }
/** /**
@@ -81,6 +80,21 @@ public class JavaFxPreferences
} }
} }
/**
* Removes all stage monitors and prepares for shutdown.
*/
public void clearStageMonitors()
{
Iterator<StageMonitor> it = mStageMonitors.iterator();
while(it.hasNext())
{
StageMonitor next = it.next();
it.remove();
next.dispose();
}
}
/** /**
* Monitors a stage's coordinates and stores location. On construction, applies stored coordinates to the stage. * Monitors a stage's coordinates and stores location. On construction, applies stored coordinates to the stage.
*/ */