Skip to content

Commit

Permalink
Window decorations: added UI value TitlePane.font to customize wind…
Browse files Browse the repository at this point in the history
…ow title font (issue #589)
  • Loading branch information
DevCharly committed Sep 23, 2022
1 parent f6c5db0 commit c228362
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -21,6 +21,7 @@ FlatLaf Change Log
(allow moving window). (issue #569)
- Option to show window icon only in frames, but not in dialogs. Set UI value
`TitlePane.showIconInDialogs` to `false`. (issue #589)
- Added UI value `TitlePane.font` to customize window title font. (issue #589)
- Added system property `flatlaf.updateUIOnSystemFontChange` to allow disabling
automatic UI update when system font changes. (issue #580)

Expand Down
Expand Up @@ -581,6 +581,7 @@ private void initFonts( UIDefaults defaults ) {

// add fonts that are not set in BasicLookAndFeel
defaults.put( "RootPane.font", activeFont );
defaults.put( "TitlePane.font", activeFont );
}

private void initDefaultFont( UIDefaults defaults ) {
Expand Down
Expand Up @@ -24,6 +24,7 @@
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.Graphics;
Expand Down Expand Up @@ -73,6 +74,7 @@
/**
* Provides the Flat LaF title bar.
*
* @uiDefault TitlePane.font Font
* @uiDefault TitlePane.background Color
* @uiDefault TitlePane.inactiveBackground Color
* @uiDefault TitlePane.foreground Color
Expand Down Expand Up @@ -105,6 +107,7 @@
public class FlatTitlePane
extends JComponent
{
/** @since 2.5 */ protected final Font titleFont = UIManager.getFont( "TitlePane.font" );
protected final Color activeBackground = UIManager.getColor( "TitlePane.background" );
protected final Color inactiveBackground = UIManager.getColor( "TitlePane.inactiveBackground" );
protected final Color activeForeground = UIManager.getColor( "TitlePane.foreground" );
Expand Down Expand Up @@ -1012,6 +1015,14 @@ protected FlatTitleLabelUI() {
super( false );
}

@Override
protected void installDefaults( JLabel c ) {
super.installDefaults( c );

if( titleFont != null )
c.setFont( titleFont );
}

@Override
protected String layoutCL( JLabel label, FontMetrics fontMetrics, String text, Icon icon,
Rectangle viewR, Rectangle iconR, Rectangle textR )
Expand Down
1 change: 1 addition & 0 deletions flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt
Expand Up @@ -1226,6 +1226,7 @@ TitlePane.closeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWin
TitlePane.closePressedBackground #c42b1ce6 90% HSLA 5 75 44 90 javax.swing.plaf.ColorUIResource [UI]
TitlePane.closePressedForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI]
TitlePane.embeddedForeground #959595 HSL 0 0 58 javax.swing.plaf.ColorUIResource [UI]
TitlePane.font [active] $defaultFont [UI]
TitlePane.foreground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI]
TitlePane.icon [lazy] 16,16 sun.swing.ImageIconUIResource [UI] (sun.awt.image.ToolkitImage)
TitlePane.iconMargins 3,8,3,8 javax.swing.plaf.InsetsUIResource [UI]
Expand Down
1 change: 1 addition & 0 deletions flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt
Expand Up @@ -1231,6 +1231,7 @@ TitlePane.closeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWin
TitlePane.closePressedBackground #c42b1ce6 90% HSLA 5 75 44 90 javax.swing.plaf.ColorUIResource [UI]
TitlePane.closePressedForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI]
TitlePane.embeddedForeground #595959 HSL 0 0 35 javax.swing.plaf.ColorUIResource [UI]
TitlePane.font [active] $defaultFont [UI]
TitlePane.foreground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI]
TitlePane.icon [lazy] 16,16 sun.swing.ImageIconUIResource [UI] (sun.awt.image.ToolkitImage)
TitlePane.iconMargins 3,8,3,8 javax.swing.plaf.InsetsUIResource [UI]
Expand Down
1 change: 1 addition & 0 deletions flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt
Expand Up @@ -1259,6 +1259,7 @@ TitlePane.closeHoverForeground #ffffff HSL 0 0 100 javax.swing.plaf.Colo
TitlePane.closeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI]
TitlePane.closePressedBackground #c42b1ce6 90% HSLA 5 75 44 90 javax.swing.plaf.ColorUIResource [UI]
TitlePane.closePressedForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI]
TitlePane.font [active] $defaultFont [UI]
TitlePane.foreground #0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI]
TitlePane.icon [lazy] 16,16 sun.swing.ImageIconUIResource [UI] (sun.awt.image.ToolkitImage)
TitlePane.iconMargins 3,8,3,8 javax.swing.plaf.InsetsUIResource [UI]
Expand Down
Expand Up @@ -996,6 +996,7 @@ TitlePane.closeIcon
TitlePane.closePressedBackground
TitlePane.closePressedForeground
TitlePane.embeddedForeground
TitlePane.font
TitlePane.foreground
TitlePane.icon
TitlePane.iconMargins
Expand Down

0 comments on commit c228362

Please sign in to comment.