From 4620f886089bd4d16a4affa46e05dd4d4688223b Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Mon, 11 Jul 2022 22:02:57 +0300 Subject: [PATCH] Simpler way to center frame on screen. --- .../svjatoslav/commons/gui/dialog/ExceptionDialog.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.java b/src/main/java/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.java index d56db29..32974f1 100755 --- a/src/main/java/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.java +++ b/src/main/java/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.java @@ -42,15 +42,7 @@ public class ExceptionDialog { frame.setSize(800, 600); frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - - centerFrameOnScreen(frame); - } - - private void centerFrameOnScreen(JFrame frame) { - final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - frame.setLocation( - (screenSize.width - frame.getWidth()) / 2, - (screenSize.height - frame.getHeight()) / 2); + frame.setLocationRelativeTo(null); // center frame on screen } private TextArea getStackTraceView(Throwable cause) { -- 2.20.1