Skip to content

Commit

Permalink
gui scaling fixes (no window packing, unify methods, MML menu)
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez committed Oct 14, 2024
1 parent 4e6f0f9 commit e60ebde
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 @@ -637,6 +637,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 e60ebde

Please sign in to comment.