Skip to content

Commit 7507734

Browse files
committed
Prevent Script Editor window from being larger than the desktop.
This can happen when using a networked account across different computers or with different monitors.
1 parent 91fadb6 commit 7507734

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/org/scijava/ui/swing/script/TextEditor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,12 @@ public void loadPreferences() {
988988

989989
final int windowWidth = prefService.getInt(getClass(), WINDOW_WIDTH, dim.width);
990990
final int windowHeight = prefService.getInt(getClass(), WINDOW_HEIGHT, dim.height);
991-
setPreferredSize(new Dimension(windowWidth, windowHeight));
991+
// Avoid creating a window larger than the desktop
992+
final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
993+
if (windowWidth > screen.getWidth() || windowHeight > screen.getHeight())
994+
setPreferredSize(new Dimension(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT));
995+
else
996+
setPreferredSize(new Dimension(windowWidth, windowHeight));
992997

993998
final int mainDivLocation = prefService.getInt(getClass(), MAIN_DIV_LOCATION, body.getDividerLocation());
994999
body.setDividerLocation(mainDivLocation);

0 commit comments

Comments
 (0)