Window decorations: glass pane no longer overlaps the FlatLaf window title bar (issue #630)

This commit is contained in:
Karl Tauber
2023-01-03 19:48:21 +01:00
parent 4b844353ee
commit 9101324a1f
4 changed files with 42 additions and 4 deletions

View File

@@ -442,6 +442,17 @@ public interface FlatClientProperties
*/
String TITLE_BAR_FOREGROUND = "JRootPane.titleBarForeground";
/**
* Specifies whether the glass pane should have full height and overlap the title bar,
* if FlatLaf window decorations are enabled. Default is {@code false}.
* <p>
* <strong>Component</strong> {@link javax.swing.JRootPane}<br>
* <strong>Value type</strong> {@link java.lang.Boolean}
*
* @since 3.1
*/
String GLASS_PANE_FULL_HEIGHT = "JRootPane.glassPaneFullHeight";
//---- JScrollBar / JScrollPane -------------------------------------------
/**

View File

@@ -362,6 +362,10 @@ public class FlatRootPaneUI
if( titlePane != null )
titlePane.titleBarColorsChanged();
break;
case FlatClientProperties.GLASS_PANE_FULL_HEIGHT:
rootPane.revalidate();
break;
}
}
@@ -442,11 +446,11 @@ public class FlatRootPaneUI
int width = rootPane.getWidth() - insets.left - insets.right;
int height = rootPane.getHeight() - insets.top - insets.bottom;
// layered pane
if( rootPane.getLayeredPane() != null )
rootPane.getLayeredPane().setBounds( x, y, width, height );
if( rootPane.getGlassPane() != null )
rootPane.getGlassPane().setBounds( x, y, width, height );
// title pane
int nextY = 0;
if( titlePane != null ) {
int prefHeight = !isFullScreen ? titlePane.getPreferredSize().height : 0;
@@ -454,6 +458,15 @@ public class FlatRootPaneUI
nextY += prefHeight;
}
// glass pane
if( rootPane.getGlassPane() != null ) {
boolean fullHeight = FlatClientProperties.clientPropertyBoolean(
rootPane, FlatClientProperties.GLASS_PANE_FULL_HEIGHT, false );
int offset = fullHeight ? 0 : nextY;
rootPane.getGlassPane().setBounds( x, y + offset, width, height - offset );
}
// menu bar
JMenuBar menuBar = rootPane.getJMenuBar();
if( menuBar != null && menuBar.isVisible() ) {
boolean embedded = !isFullScreen && titlePane != null && titlePane.isMenuBarEmbedded();
@@ -467,10 +480,12 @@ public class FlatRootPaneUI
}
}
// content pane
Container contentPane = rootPane.getContentPane();
if( contentPane != null )
contentPane.setBounds( 0, nextY, width, Math.max( height - nextY, 0 ) );
// title pane
if( titlePane != null )
titlePane.menuBarLayouted();
}