Skip to content

Commit

Permalink
Merge pull request #6103 from SJuliez/gui-scaling-fixes
Browse files Browse the repository at this point in the history
GUI scaling fixes
  • Loading branch information
SJuliez authored Oct 15, 2024
2 parents dc04080 + e60ebde commit ec3a30f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
16 changes: 1 addition & 15 deletions megamek/src/megamek/client/ui/swing/MegaMekGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
Expand Down Expand Up @@ -1202,22 +1201,9 @@ public static void updateGuiScaling() {
private static void setLookAndFeel() {
try {
UIManager.setLookAndFeel(GUIPreferences.getInstance().getUITheme());
updateAfterUiChange();
UIUtil.updateAfterUiChange();
} catch (Exception ex) {
logger.error("setLookAndFeel() Exception", ex);
}
}

/**
* Updates all existing windows and frames. Use after a gui scale change or look-and-feel change.
*/
public static void updateAfterUiChange() {
for (Window window : Window.getWindows()) {
SwingUtilities.updateComponentTreeUI(window);
window.invalidate();
window.validate();
window.pack();
window.repaint();
}
}
}
12 changes: 12 additions & 0 deletions megamek/src/megamek/client/ui/swing/util/UIUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,18 @@ public static void setHighQualityRendering(Graphics graph) {
}
}

/**
* Updates all existing windows and frames. Use after a gui scale change or look-and-feel change.
*/
public static void updateAfterUiChange() {
for (Window window : Window.getWindows()) {
SwingUtilities.updateComponentTreeUI(window);
window.invalidate();
window.validate();
window.repaint();
}
}

/** A specialized panel for the header of a section. */
public static class Header extends JPanel {
private static final long serialVersionUID = -6235772150005269143L;
Expand Down

0 comments on commit ec3a30f

Please sign in to comment.