From: Svjatoslav Agejenko Date: Mon, 11 Jul 2022 19:02:57 +0000 (+0300) Subject: Simpler way to center frame on screen. X-Git-Tag: svjatoslavcommons-1.9~1 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=svjatoslav_commons.git;a=commitdiff_plain;h=4620f886089bd4d16a4affa46e05dd4d4688223b Simpler way to center frame on screen. --- 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) {