From 797830ff96fcef58dbbfbe926cff8ad8f7edf328 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Tue, 21 Jul 2020 18:23:57 +0200 Subject: [PATCH] InternalFrame: title pane height was too small when iconify, maximize and close buttons are hidden (issue #132) --- CHANGELOG.md | 2 ++ .../flatlaf/ui/FlatInternalFrameTitlePane.java | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4eae0897..f46ac370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ FlatLaf Change Log - Custom window decorations: Fixed maximized window bounds when programmatically maximizing window. E.g. restoring window state at startup. (issue #129) +- InternalFrame: Title pane height was too small when iconify, maximize and close + buttons are hidden. (issue #132) ## 0.38 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java index fa0913e8..3e4f7c1a 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java @@ -92,7 +92,21 @@ public class FlatInternalFrameTitlePane updateFrameIcon(); updateColors(); - buttonPanel = new JPanel(); + buttonPanel = new JPanel() { + @Override + public Dimension getPreferredSize() { + Dimension size = super.getPreferredSize(); + int height = size.height; + // use height of invisible buttons to always have same title pane height + if( !iconButton.isVisible() ) + height = Math.max( height, iconButton.getPreferredSize().height ); + if( !maxButton.isVisible() ) + height = Math.max( height, maxButton.getPreferredSize().height ); + if( !closeButton.isVisible() ) + height = Math.max( height, closeButton.getPreferredSize().height ); + return new Dimension( size.width, height ); + } + }; buttonPanel.setLayout( new BoxLayout( buttonPanel, BoxLayout.LINE_AXIS ) ); buttonPanel.setOpaque( false );