Window decorations: added option to show window icon only in frames, but not in dialogs (issue #589)

This commit is contained in:
Karl Tauber
2022-09-22 23:15:07 +02:00
parent 86a4f306c6
commit 78e7839213
7 changed files with 18 additions and 4 deletions

View File

@@ -14,9 +14,11 @@ FlatLaf Change Log
is disabled. (issue #501) is disabled. (issue #501)
- TabbedPane: New option to disable tab run rotation in wrap layout. Set UI - TabbedPane: New option to disable tab run rotation in wrap layout. Set UI
value `TabbedPane.rotateTabRuns` to `false`. (issue #574) value `TabbedPane.rotateTabRuns` to `false`. (issue #574)
- Native window decorations (Windows 10/11 only): Added client property to mark - Window decorations:
components in embedded menu bar as "caption" (allow moving window). (issue - Added client property to mark components in embedded menu bar as "caption"
#569) (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 system property `flatlaf.updateUIOnSystemFontChange` to allow disabling - Added system property `flatlaf.updateUIOnSystemFontChange` to allow disabling
automatic UI update when system font changes. (issue #580) automatic UI update when system font changes. (issue #580)

View File

@@ -55,6 +55,7 @@ import javax.swing.BoxLayout;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JMenuBar; import javax.swing.JMenuBar;
import javax.swing.JPanel; import javax.swing.JPanel;
@@ -80,6 +81,7 @@ import com.formdev.flatlaf.util.UIScale;
* @uiDefault TitlePane.borderColor Color optional * @uiDefault TitlePane.borderColor Color optional
* @uiDefault TitlePane.unifiedBackground boolean * @uiDefault TitlePane.unifiedBackground boolean
* @uiDefault TitlePane.showIcon boolean * @uiDefault TitlePane.showIcon boolean
* @uiDefault TitlePane.showIconInDialogs boolean
* @uiDefault TitlePane.noIconLeftGap int * @uiDefault TitlePane.noIconLeftGap int
* @uiDefault TitlePane.iconSize Dimension * @uiDefault TitlePane.iconSize Dimension
* @uiDefault TitlePane.iconMargins Insets * @uiDefault TitlePane.iconMargins Insets
@@ -111,6 +113,7 @@ public class FlatTitlePane
protected final Color borderColor = UIManager.getColor( "TitlePane.borderColor" ); protected final Color borderColor = UIManager.getColor( "TitlePane.borderColor" );
/** @since 2 */ protected final boolean showIcon = FlatUIUtils.getUIBoolean( "TitlePane.showIcon", true ); /** @since 2 */ protected final boolean showIcon = FlatUIUtils.getUIBoolean( "TitlePane.showIcon", true );
/** @since 2.5 */ protected final boolean showIconInDialogs = FlatUIUtils.getUIBoolean( "TitlePane.showIconInDialogs", true );
/** @since 2 */ protected final int noIconLeftGap = FlatUIUtils.getUIInt( "TitlePane.noIconLeftGap", 8 ); /** @since 2 */ protected final int noIconLeftGap = FlatUIUtils.getUIInt( "TitlePane.noIconLeftGap", 8 );
protected final Dimension iconSize = UIManager.getDimension( "TitlePane.iconSize" ); protected final Dimension iconSize = UIManager.getDimension( "TitlePane.iconSize" );
/** @since 2.4 */ protected final int titleMinimumWidth = FlatUIUtils.getUIInt( "TitlePane.titleMinimumWidth", 60 ); /** @since 2.4 */ protected final int titleMinimumWidth = FlatUIUtils.getUIInt( "TitlePane.titleMinimumWidth", 60 );
@@ -389,9 +392,13 @@ public class FlatTitlePane
} }
protected void updateIcon() { protected void updateIcon() {
boolean defaultShowIcon = showIcon;
if( !showIconInDialogs && rootPane.getParent() instanceof JDialog )
defaultShowIcon = false;
// get window images // get window images
List<Image> images = null; List<Image> images = null;
if( clientPropertyBoolean( rootPane, TITLE_BAR_SHOW_ICON, showIcon ) ) { if( clientPropertyBoolean( rootPane, TITLE_BAR_SHOW_ICON, defaultShowIcon ) ) {
images = window.getIconImages(); images = window.getIconImages();
if( images.isEmpty() ) { if( images.isEmpty() ) {
// search in owners // search in owners

View File

@@ -785,6 +785,7 @@ TitlePane.useWindowDecorations = true
TitlePane.menuBarEmbedded = true TitlePane.menuBarEmbedded = true
TitlePane.unifiedBackground = true TitlePane.unifiedBackground = true
TitlePane.showIcon = true TitlePane.showIcon = true
TitlePane.showIconInDialogs = true
TitlePane.noIconLeftGap = 8 TitlePane.noIconLeftGap = 8
TitlePane.iconSize = 16,16 TitlePane.iconSize = 16,16
TitlePane.iconMargins = 3,8,3,8 TitlePane.iconMargins = 3,8,3,8

View File

@@ -1242,6 +1242,7 @@ TitlePane.noIconLeftGap 8
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.showIcon true TitlePane.showIcon true
TitlePane.showIconBesideTitle false TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60 TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true TitlePane.unifiedBackground true

View File

@@ -1247,6 +1247,7 @@ TitlePane.noIconLeftGap 8
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.showIcon true TitlePane.showIcon true
TitlePane.showIconBesideTitle false TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60 TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true TitlePane.unifiedBackground true

View File

@@ -1275,6 +1275,7 @@ TitlePane.noIconLeftGap 8
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.showIcon true TitlePane.showIcon true
TitlePane.showIconBesideTitle false TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60 TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true TitlePane.unifiedBackground true

View File

@@ -1012,6 +1012,7 @@ TitlePane.noIconLeftGap
TitlePane.restoreIcon TitlePane.restoreIcon
TitlePane.showIcon TitlePane.showIcon
TitlePane.showIconBesideTitle TitlePane.showIconBesideTitle
TitlePane.showIconInDialogs
TitlePane.titleMargins TitlePane.titleMargins
TitlePane.titleMinimumWidth TitlePane.titleMinimumWidth
TitlePane.unifiedBackground TitlePane.unifiedBackground