mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
Native window decorations: support changing title bar background and foreground colors per window (via client property) also if unified window title bar is enabled
This commit is contained in:
@@ -106,18 +106,18 @@ public class FlatMenuBarUI
|
||||
if( rootPane == null || !(rootPane.getParent() instanceof Window) || rootPane.getJMenuBar() != c )
|
||||
return background;
|
||||
|
||||
// paint background for unified title pane in color of parent
|
||||
// use parent background for unified title pane
|
||||
// (not storing value of "TitlePane.unifiedBackground" in class to allow changing at runtime)
|
||||
if( UIManager.getBoolean( "TitlePane.unifiedBackground" ) &&
|
||||
FlatNativeWindowBorder.hasCustomDecoration( (Window) rootPane.getParent() ) )
|
||||
return FlatUIUtils.getParentBackground( c );
|
||||
background = FlatUIUtils.getParentBackground( c );
|
||||
|
||||
// paint background in full screen mode
|
||||
if( FlatUIUtils.isFullScreen( rootPane ) )
|
||||
return background;
|
||||
|
||||
// do not paint background if menu bar is embedded into title pane
|
||||
return FlatRootPaneUI.isMenuBarEmbedded( rootPane ) ? null :background;
|
||||
return FlatRootPaneUI.isMenuBarEmbedded( rootPane ) ? null : background;
|
||||
}
|
||||
|
||||
//---- class TakeFocus ----------------------------------------------------
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.formdev.flatlaf.ui;
|
||||
|
||||
import static com.formdev.flatlaf.FlatClientProperties.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
@@ -265,8 +266,8 @@ public class FlatTitlePane
|
||||
}
|
||||
|
||||
protected void activeChanged( boolean active ) {
|
||||
Color background = FlatClientProperties.clientPropertyColor( rootPane, FlatClientProperties.TITLE_BAR_BACKGROUND, null );
|
||||
Color foreground = FlatClientProperties.clientPropertyColor( rootPane, FlatClientProperties.TITLE_BAR_FOREGROUND, null );
|
||||
Color background = clientPropertyColor( rootPane, TITLE_BAR_BACKGROUND, null );
|
||||
Color foreground = clientPropertyColor( rootPane, TITLE_BAR_FOREGROUND, null );
|
||||
Color titleForeground = foreground;
|
||||
if( background == null )
|
||||
background = FlatUIUtils.nonUIResource( active ? activeBackground : inactiveBackground );
|
||||
@@ -537,7 +538,8 @@ debug*/
|
||||
@Override
|
||||
protected void paintComponent( Graphics g ) {
|
||||
// not storing value of "TitlePane.unifiedBackground" in class to allow changing at runtime
|
||||
g.setColor( UIManager.getBoolean( "TitlePane.unifiedBackground" )
|
||||
g.setColor( (UIManager.getBoolean( "TitlePane.unifiedBackground" ) &&
|
||||
clientPropertyColor( rootPane, TITLE_BAR_BACKGROUND, null ) == null)
|
||||
? FlatUIUtils.getParentBackground( this )
|
||||
: getBackground() );
|
||||
g.fillRect( 0, 0, getWidth(), getHeight() );
|
||||
|
||||
Reference in New Issue
Block a user