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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user