mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-09 08:15:09 +03:00
Window decorations: left indent was lost when icon is hidden and switching Laf (regression in commit 005c9f471e6bc3ea5d708a08e8fb0b087b2c3382; PR #429)
This commit is contained in:
@@ -19,9 +19,7 @@ package com.formdev.flatlaf.ui;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.Insets;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
@@ -230,7 +228,7 @@ public class FlatOptionPaneUI
|
||||
// use non-UIResource borders to avoid that they are replaced when switching LaF
|
||||
Border border = panel.getBorder();
|
||||
if( border instanceof UIResource )
|
||||
panel.setBorder( new NonUIResourceBorder( border ) );
|
||||
panel.setBorder( FlatUIUtils.nonUIResource( border ) );
|
||||
}
|
||||
|
||||
if( child instanceof Container )
|
||||
@@ -256,31 +254,4 @@ public class FlatOptionPaneUI
|
||||
protected boolean getSizeButtonsToSameWidth() {
|
||||
return sameSizeButtons;
|
||||
}
|
||||
|
||||
//---- class NonUIResourceBorder ------------------------------------------
|
||||
|
||||
private static class NonUIResourceBorder
|
||||
implements Border
|
||||
{
|
||||
private final Border delegate;
|
||||
|
||||
NonUIResourceBorder( Border delegate ) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
|
||||
delegate.paintBorder( c, g, x, y, width, height );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets( Component c ) {
|
||||
return delegate.getBorderInsets( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBorderOpaque() {
|
||||
return delegate.isBorderOpaque();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ public class FlatTitlePane
|
||||
|
||||
// show/hide icon
|
||||
iconLabel.setVisible( hasIcon );
|
||||
leftPanel.setBorder( hasIcon ? null : new FlatEmptyBorder( 0, noIconLeftGap, 0, 0 ) );
|
||||
leftPanel.setBorder( hasIcon ? null : FlatUIUtils.nonUIResource( new FlatEmptyBorder( 0, noIconLeftGap, 0, 0 ) ) );
|
||||
|
||||
updateNativeTitleBarHeightAndHitTestSpotsLater();
|
||||
}
|
||||
|
||||
@@ -188,6 +188,11 @@ public class FlatUIUtils
|
||||
return (font instanceof UIResource) ? font.deriveFont( font.getStyle() ) : font;
|
||||
}
|
||||
|
||||
/** @since 2 */
|
||||
public static Border nonUIResource( Border border ) {
|
||||
return (border instanceof UIResource) ? new NonUIResourceBorder( border ) : border;
|
||||
}
|
||||
|
||||
public static int minimumWidth( JComponent c, int minimumWidth ) {
|
||||
return FlatClientProperties.clientPropertyInt( c, FlatClientProperties.MINIMUM_WIDTH, minimumWidth );
|
||||
}
|
||||
@@ -982,4 +987,31 @@ debug*/
|
||||
repaintComponent.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
//---- class NonUIResourceBorder ------------------------------------------
|
||||
|
||||
private static class NonUIResourceBorder
|
||||
implements Border
|
||||
{
|
||||
private final Border delegate;
|
||||
|
||||
NonUIResourceBorder( Border delegate ) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
|
||||
delegate.paintBorder( c, g, x, y, width, height );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets( Component c ) {
|
||||
return delegate.getBorderInsets( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBorderOpaque() {
|
||||
return delegate.isBorderOpaque();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user