From 36393697725bcea5947562bede66964bc098b552 Mon Sep 17 00:00:00 2001 From: Jannis Weis <31143295+weisJ@users.noreply.github.com> Date: Sun, 13 Feb 2022 17:12:24 +0100 Subject: [PATCH] Ensure window title uses correct font on Windows --- .../platform/windows/ui/WindowsTitlePane.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java index dcf65dd4..8ae91336 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java @@ -110,7 +110,6 @@ public class WindowsTitlePane extends CustomTitlePane { installSubcomponents(); menuBarStealer.install(); updateTitleBarVisibility(); - installDefaults(); setLayout(createLayout()); } @@ -254,7 +253,7 @@ public class WindowsTitlePane extends CustomTitlePane { private void installSubcomponents() { titleLabel = new JLabel(); titleLabel.setHorizontalAlignment(JLabel.LEFT); - titleLabel.setFont(getFont()); + setTitleFont(getFont()); createIcons(); createActions(); @@ -308,6 +307,12 @@ public class WindowsTitlePane extends CustomTitlePane { inactiveForeground = new Color(inactiveForeground.getRGB()); } + @Override + public void updateUI() { + super.updateUI(); + installDefaults(); + } + private void installDefaults() { setFont(UIManager.getFont("InternalFrame.titleFont", getLocale())); } @@ -315,7 +320,13 @@ public class WindowsTitlePane extends CustomTitlePane { @Override public void setFont(final Font font) { super.setFont(font); - if (titleLabel != null) titleLabel.setFont(font); + setTitleFont(font); + } + + private void setTitleFont(final Font font) { + if (titleLabel != null) { + titleLabel.setFont(font); + } } protected JButton createWindowIcon() {