From 03bafbca9f4cf2ca4094aaf67c74d7ba4bff2724 Mon Sep 17 00:00:00 2001 From: Hugo Leblanc Date: Thu, 4 Jul 2024 11:00:28 -0400 Subject: [PATCH] Fix #27 - Change service to get initial screen size Toolkit.getDefaultToolkit().getScreenSize() is not especially aware of High DPI screen of the size of usable real-estate. Replaced it with GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds() to have usable values for the first layout generation. --- src/rars/venus/VenusUI.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rars/venus/VenusUI.java b/src/rars/venus/VenusUI.java index a4046cc2..80d28b9a 100644 --- a/src/rars/venus/VenusUI.java +++ b/src/rars/venus/VenusUI.java @@ -52,10 +52,10 @@ a copy of this software and associated documentation files (the * @author Sanderson and Team JSpim **/ - /* Heavily modified by Pete Sanderson, July 2004, to incorporate JSPIMMenu and JSPIMToolbar - * not as subclasses of JMenuBar and JToolBar, but as instances of them. They are both - * here primarily so both can share the Action objects. - */ +/* Heavily modified by Pete Sanderson, July 2004, to incorporate JSPIMMenu and JSPIMToolbar + * not as subclasses of JMenuBar and JToolBar, but as instances of them. They are both + * here primarily so both can share the Action objects. + */ public class VenusUI extends JFrame { VenusUI mainUI; @@ -126,9 +126,9 @@ public VenusUI(String name, ArrayList paths) { mainUI = this; Globals.setGui(this); this.editor = new Editor(this); - - double screenWidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); - double screenHeight = Toolkit.getDefaultToolkit().getScreenSize().getHeight(); + Rectangle maximumWindowBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); + double screenWidth = maximumWindowBounds.getWidth(); + double screenHeight = maximumWindowBounds.getHeight(); // basically give up some screen space if running at 800 x 600 double messageWidthPct = (screenWidth < 1000.0) ? 0.67 : 0.73; double messageHeightPct = (screenWidth < 1000.0) ? 0.12 : 0.15;