From 269e854279f7fd841f4f9ad72f31af084326d806 Mon Sep 17 00:00:00 2001 From: Jannis Weis <31143295+weisJ@users.noreply.github.com> Date: Wed, 2 Feb 2022 20:25:20 +0100 Subject: [PATCH] Decorations: Adjust windows titlepane to height of title font --- .../darklaf/platform/windows/ui/WindowsTitlePane.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 c3eb1f31..dcf65dd4 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 @@ -254,6 +254,7 @@ public class WindowsTitlePane extends CustomTitlePane { private void installSubcomponents() { titleLabel = new JLabel(); titleLabel.setHorizontalAlignment(JLabel.LEFT); + titleLabel.setFont(getFont()); createIcons(); createActions(); @@ -311,6 +312,12 @@ public class WindowsTitlePane extends CustomTitlePane { setFont(UIManager.getFont("InternalFrame.titleFont", getLocale())); } + @Override + public void setFont(final Font font) { + super.setFont(font); + if (titleLabel != null) titleLabel.setFont(font); + } + protected JButton createWindowIcon() { JButton button = new JButton(); button.putClientProperty("JButton.noShadowOverwrite", true); @@ -702,7 +709,7 @@ public class WindowsTitlePane extends CustomTitlePane { private int computeHeight() { if (hideTitleBar()) return 0; - FontMetrics fm = rootPane.getFontMetrics(getFont()); + FontMetrics fm = titleLabel.getFontMetrics(titleLabel.getFont()); int height = fm.getHeight() + 7; if (menuBarStealer.hasMenuBar()) { height = Math.max(height, menuBarStealer.getMenuBar().getMinimumSize().height);