mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-14 07:47:12 -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 )
|
if( rootPane == null || !(rootPane.getParent() instanceof Window) || rootPane.getJMenuBar() != c )
|
||||||
return background;
|
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)
|
// (not storing value of "TitlePane.unifiedBackground" in class to allow changing at runtime)
|
||||||
if( UIManager.getBoolean( "TitlePane.unifiedBackground" ) &&
|
if( UIManager.getBoolean( "TitlePane.unifiedBackground" ) &&
|
||||||
FlatNativeWindowBorder.hasCustomDecoration( (Window) rootPane.getParent() ) )
|
FlatNativeWindowBorder.hasCustomDecoration( (Window) rootPane.getParent() ) )
|
||||||
return FlatUIUtils.getParentBackground( c );
|
background = FlatUIUtils.getParentBackground( c );
|
||||||
|
|
||||||
// paint background in full screen mode
|
// paint background in full screen mode
|
||||||
if( FlatUIUtils.isFullScreen( rootPane ) )
|
if( FlatUIUtils.isFullScreen( rootPane ) )
|
||||||
return background;
|
return background;
|
||||||
|
|
||||||
// do not paint background if menu bar is embedded into title pane
|
// 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 ----------------------------------------------------
|
//---- class TakeFocus ----------------------------------------------------
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
|
import static com.formdev.flatlaf.FlatClientProperties.*;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
@@ -265,8 +266,8 @@ public class FlatTitlePane
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void activeChanged( boolean active ) {
|
protected void activeChanged( boolean active ) {
|
||||||
Color background = FlatClientProperties.clientPropertyColor( rootPane, FlatClientProperties.TITLE_BAR_BACKGROUND, null );
|
Color background = clientPropertyColor( rootPane, TITLE_BAR_BACKGROUND, null );
|
||||||
Color foreground = FlatClientProperties.clientPropertyColor( rootPane, FlatClientProperties.TITLE_BAR_FOREGROUND, null );
|
Color foreground = clientPropertyColor( rootPane, TITLE_BAR_FOREGROUND, null );
|
||||||
Color titleForeground = foreground;
|
Color titleForeground = foreground;
|
||||||
if( background == null )
|
if( background == null )
|
||||||
background = FlatUIUtils.nonUIResource( active ? activeBackground : inactiveBackground );
|
background = FlatUIUtils.nonUIResource( active ? activeBackground : inactiveBackground );
|
||||||
@@ -537,7 +538,8 @@ debug*/
|
|||||||
@Override
|
@Override
|
||||||
protected void paintComponent( Graphics g ) {
|
protected void paintComponent( Graphics g ) {
|
||||||
// not storing value of "TitlePane.unifiedBackground" in class to allow changing at runtime
|
// 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 )
|
? FlatUIUtils.getParentBackground( this )
|
||||||
: getBackground() );
|
: getBackground() );
|
||||||
g.fillRect( 0, 0, getWidth(), getHeight() );
|
g.fillRect( 0, 0, getWidth(), getHeight() );
|
||||||
|
|||||||
Reference in New Issue
Block a user