From 44e45cb7013e160bbe1afbe96435d03bc80aef54 Mon Sep 17 00:00:00 2001 From: Tobias Schulte Date: Fri, 4 May 2018 09:06:56 +0200 Subject: [PATCH] set window to decorated even if error occurs during very early stage When the window is undecorated and an error occurs very early, e.g. during java version check, the order of the calls in the fail method is significant. super.fail() will call setStatusAsync, which will create the interface using EventQueue.invokeLater, if it does not exist yet. Therefore we must first call super.fail(), and then asynchronously make the window decorated again. Otherwise the window might not be created yet. Closes #57 --- .../getdown/launcher/GetdownApp.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/threerings/getdown/launcher/GetdownApp.java b/src/main/java/com/threerings/getdown/launcher/GetdownApp.java index e5f0386..050ba36 100644 --- a/src/main/java/com/threerings/getdown/launcher/GetdownApp.java +++ b/src/main/java/com/threerings/getdown/launcher/GetdownApp.java @@ -5,6 +5,7 @@ package com.threerings.getdown.launcher; +import java.awt.EventQueue; import java.awt.Color; import java.awt.Container; import java.awt.IllegalComponentStateException; @@ -22,7 +23,6 @@ import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import javax.swing.JFrame; @@ -231,20 +231,25 @@ public class GetdownApp @Override protected void fail (String message) { - // if the frame was set to be undecorated, make window decoration available - // to allow the user to close the window - if (_frame != null && _frame.isUndecorated()) { - _frame.dispose(); - Color background = _frame.getBackground(); - if (background != null && background.getAlpha() < 255) { - // decorated windows do not allow alpha backgrounds - _frame.setBackground( - new Color(background.getRed(), background.getGreen(), background.getBlue())); - } - _frame.setUndecorated(false); - showContainer(); - } super.fail(message); + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + // if the frame was set to be undecorated, make window decoration available + // to allow the user to close the window + if (_frame != null && _frame.isUndecorated()) { + _frame.dispose(); + Color background = _frame.getBackground(); + if (background != null && background.getAlpha() < 255) { + // decorated windows do not allow alpha backgrounds + _frame.setBackground( + new Color(background.getRed(), background.getGreen(), background.getBlue())); + } + _frame.setUndecorated(false); + showContainer(); + } + } + }); } protected JFrame _frame;