diff options
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java index ce13107d..cf9bc08d 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java @@ -6,6 +6,7 @@ import java.awt.Frame; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Insets; +import java.awt.KeyboardFocusManager; import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; @@ -109,7 +110,7 @@ public class Gui { /** * Gets the given dimension scaled to the saved scaling factor - * + * * @param width starting width to scale * @param height starting height to scale * @return scaled dimension @@ -118,6 +119,7 @@ public class Gui { int scale = Config.getFontScaling(); return new Dimension(width * scale / 100, height * scale / 100); } + /** * Get the {@link GraphicsDevice} which the given {@link Point} lies in. * @@ -267,16 +269,15 @@ public class Gui { if (logger != null) logger.log(messageType.logPriority, message, exception); // Only needs to be done, if parent isn't already a window - if(!(parent instanceof Window)){ - if (parent != null) { - Window ancestor = SwingUtilities.getWindowAncestor(parent); - if (ancestor != null) { - parent = ancestor; - } + if (parent == null) { + parent = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); + } else if (!(parent instanceof Window)) { + Window ancestor = SwingUtilities.getWindowAncestor(parent); + if (ancestor != null) { + parent = ancestor; } } - if (exception != null) message += "\n\n" + exception.getClass().getSimpleName() + "\n" + exception.getMessage() + "\n" + " (Siehe Logdatei)"; |