Skip to content

Commit ac484c0

Browse files
authored
Merge pull request #8344 from IllianiBird/tinyScreenFix
Fix: Stopped Preset Picker Extending Beyond Visible Screen Limits on Windows Systems With Tiny Screens
2 parents 49be401 + 0ec7c66 commit ac484c0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

MekHQ/src/mekhq/gui/campaignOptions/SelectPresetDialog.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@
3939

4040
import java.awt.BorderLayout;
4141
import java.awt.Component;
42+
import java.awt.Dimension;
4243
import java.awt.GridBagConstraints;
4344
import java.awt.GridBagLayout;
4445
import java.awt.Insets;
46+
import java.awt.Toolkit;
4547
import javax.swing.*;
4648
import javax.swing.GroupLayout.Alignment;
4749
import javax.swing.LayoutStyle.ComponentPlacement;
@@ -206,7 +208,18 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i
206208

207209
add(buttonPanel, BorderLayout.PAGE_END);
208210

211+
Toolkit toolkit = Toolkit.getDefaultToolkit();
212+
Dimension screen = toolkit.getScreenSize();
213+
Insets insets = getToolkit().getScreenInsets(getGraphicsConfiguration());
214+
215+
int maxHeight = screen.height - insets.top - insets.bottom;
216+
209217
pack();
218+
Dimension size = getSize();
219+
if (size.height > maxHeight) {
220+
setSize(new Dimension(size.width, maxHeight));
221+
}
222+
210223
setAlwaysOnTop(true);
211224
setResizable(false);
212225
setLocationRelativeTo(null);

0 commit comments

Comments
 (0)