From eaf55f20991fdc59237ce3b649415d6929dcf635 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 8 Aug 2021 19:15:10 +0200 Subject: [PATCH] Theme Editor: store unscaled window bounds in preferences so that using Java 8 or 9+ results in same size on screen --- .../flatlaf/themeeditor/FlatThemeFileEditor.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java index 93f3b516..62cc9b3d 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java @@ -429,10 +429,10 @@ public class FlatThemeFileEditor List list = StringUtils.split( windowBoundsStr, ',' ); if( list.size() >= 4 ) { try { - int x = Integer.parseInt( list.get( 0 ) ); - int y = Integer.parseInt( list.get( 1 ) ); - int w = Integer.parseInt( list.get( 2 ) ); - int h = Integer.parseInt( list.get( 3 ) ); + int x = UIScale.scale( Integer.parseInt( list.get( 0 ) ) ); + int y = UIScale.scale( Integer.parseInt( list.get( 1 ) ) ); + int w = UIScale.scale( Integer.parseInt( list.get( 2 ) ) ); + int h = UIScale.scale( Integer.parseInt( list.get( 3 ) ) ); // limit to screen size GraphicsConfiguration gc = getGraphicsConfiguration(); @@ -464,7 +464,11 @@ public class FlatThemeFileEditor private void saveWindowBounds() { Rectangle r = getBounds(); - state.put( KEY_WINDOW_BOUNDS, r.x + "," + r.y + ',' + r.width + ',' + r.height ); + int x = UIScale.unscale( r.x ); + int y = UIScale.unscale( r.y ); + int width = UIScale.unscale( r.width ); + int height = UIScale.unscale( r.height ); + state.put( KEY_WINDOW_BOUNDS, x + "," + y + ',' + width + ',' + height ); } private static void putPrefsString( Preferences prefs, String key, String value ) {