Window decorations: added UI value TitlePane.font to customize window title font (issue #589)

This commit is contained in:
Karl Tauber
2022-09-23 11:57:38 +02:00
parent f6c5db07f2
commit c228362c01
7 changed files with 17 additions and 0 deletions

View File

@@ -581,6 +581,7 @@ public abstract class FlatLaf
// add fonts that are not set in BasicLookAndFeel
defaults.put( "RootPane.font", activeFont );
defaults.put( "TitlePane.font", activeFont );
}
private void initDefaultFont( UIDefaults defaults ) {

View File

@@ -24,6 +24,7 @@ import java.awt.Container;
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;
@@ -73,6 +74,7 @@ import com.formdev.flatlaf.util.UIScale;
/**
* Provides the Flat LaF title bar.
*
* @uiDefault TitlePane.font Font
* @uiDefault TitlePane.background Color
* @uiDefault TitlePane.inactiveBackground Color
* @uiDefault TitlePane.foreground Color
@@ -105,6 +107,7 @@ import com.formdev.flatlaf.util.UIScale;
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" );
@@ -1012,6 +1015,14 @@ debug*/
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 )