mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 15:07:11 -06: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.Component;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.Insets;
|
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
@@ -230,7 +228,7 @@ public class FlatOptionPaneUI
|
|||||||
// use non-UIResource borders to avoid that they are replaced when switching LaF
|
// use non-UIResource borders to avoid that they are replaced when switching LaF
|
||||||
Border border = panel.getBorder();
|
Border border = panel.getBorder();
|
||||||
if( border instanceof UIResource )
|
if( border instanceof UIResource )
|
||||||
panel.setBorder( new NonUIResourceBorder( border ) );
|
panel.setBorder( FlatUIUtils.nonUIResource( border ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( child instanceof Container )
|
if( child instanceof Container )
|
||||||
@@ -256,31 +254,4 @@ public class FlatOptionPaneUI
|
|||||||
protected boolean getSizeButtonsToSameWidth() {
|
protected boolean getSizeButtonsToSameWidth() {
|
||||||
return sameSizeButtons;
|
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
|
// show/hide icon
|
||||||
iconLabel.setVisible( hasIcon );
|
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();
|
updateNativeTitleBarHeightAndHitTestSpotsLater();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,6 +188,11 @@ public class FlatUIUtils
|
|||||||
return (font instanceof UIResource) ? font.deriveFont( font.getStyle() ) : font;
|
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 ) {
|
public static int minimumWidth( JComponent c, int minimumWidth ) {
|
||||||
return FlatClientProperties.clientPropertyInt( c, FlatClientProperties.MINIMUM_WIDTH, minimumWidth );
|
return FlatClientProperties.clientPropertyInt( c, FlatClientProperties.MINIMUM_WIDTH, minimumWidth );
|
||||||
}
|
}
|
||||||
@@ -982,4 +987,31 @@ debug*/
|
|||||||
repaintComponent.repaint();
|
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