Styling: MigLayout visual padding was not updated after applying style to Button, ComboBox, Spinner, TextField (and subclasses) and ToggleButton (issue #965)

This commit is contained in:
Karl Tauber
2025-02-05 12:55:12 +01:00
parent 1f594b2ba8
commit 072cc3c488
7 changed files with 44 additions and 20 deletions

View File

@@ -32,6 +32,9 @@ FlatLaf Change Log
than 100% (e.g. `-Dflatlaf.uiScale=75%`). (issue #951) than 100% (e.g. `-Dflatlaf.uiScale=75%`). (issue #951)
- Linux: Fixed occasional maximizing of window when single-clicking the - Linux: Fixed occasional maximizing of window when single-clicking the
window's title bar. (issue #637) window's title bar. (issue #637)
- Styling: MigLayout visual padding was not updated after applying style to
Button, ComboBox, Spinner, TextField (and subclasses) and ToggleButton. (issue
#965)
- Linux: Popups (menus and combobox lists) were not hidden when window is moved, - Linux: Popups (menus and combobox lists) were not hidden when window is moved,
resized, maximized, restored, iconified or switched to another window. (issue resized, maximized, restored, iconified or switched to another window. (issue
#962) #962)

View File

@@ -280,8 +280,6 @@ public class FlatButtonUI
LookAndFeel.installProperty( b, "opaque", false ); LookAndFeel.installProperty( b, "opaque", false );
LookAndFeel.installProperty( b, "iconTextGap", scale( iconTextGap ) ); LookAndFeel.installProperty( b, "iconTextGap", scale( iconTextGap ) );
MigLayoutVisualPadding.install( b );
} }
@Override @Override
@@ -291,10 +289,23 @@ public class FlatButtonUI
oldStyleValues = null; oldStyleValues = null;
borderShared = null; borderShared = null;
MigLayoutVisualPadding.uninstall( b );
defaults_initialized = false; defaults_initialized = false;
} }
@Override
protected void installListeners( AbstractButton b ) {
super.installListeners( b );
MigLayoutVisualPadding.install( b );
}
@Override
protected void uninstallListeners( AbstractButton b ) {
super.uninstallListeners( b );
MigLayoutVisualPadding.uninstall( b );
}
@Override @Override
protected BasicButtonListener createButtonListener( AbstractButton b ) { protected BasicButtonListener createButtonListener( AbstractButton b ) {
return new FlatButtonListener( b ); return new FlatButtonListener( b );

View File

@@ -225,6 +225,8 @@ public class FlatComboBoxUI
} }
}; };
comboBox.addMouseListener( hoverListener ); comboBox.addMouseListener( hoverListener );
MigLayoutVisualPadding.install( comboBox );
} }
@Override @Override
@@ -233,6 +235,8 @@ public class FlatComboBoxUI
comboBox.removeMouseListener( hoverListener ); comboBox.removeMouseListener( hoverListener );
hoverListener = null; hoverListener = null;
MigLayoutVisualPadding.uninstall( comboBox );
} }
@Override @Override
@@ -274,8 +278,6 @@ public class FlatComboBoxUI
comboBox.setMaximumRowCount( maximumRowCount ); comboBox.setMaximumRowCount( maximumRowCount );
paddingBorder = new CellPaddingBorder( padding ); paddingBorder = new CellPaddingBorder( padding );
MigLayoutVisualPadding.install( comboBox );
} }
@Override @Override
@@ -304,8 +306,6 @@ public class FlatComboBoxUI
oldStyleValues = null; oldStyleValues = null;
borderShared = null; borderShared = null;
MigLayoutVisualPadding.uninstall( comboBox );
} }
@Override @Override

View File

@@ -140,8 +140,6 @@ public class FlatSpinnerUI
buttonHoverArrowColor = UIManager.getColor( "Spinner.buttonHoverArrowColor" ); buttonHoverArrowColor = UIManager.getColor( "Spinner.buttonHoverArrowColor" );
buttonPressedArrowColor = UIManager.getColor( "Spinner.buttonPressedArrowColor" ); buttonPressedArrowColor = UIManager.getColor( "Spinner.buttonPressedArrowColor" );
padding = UIManager.getInsets( "Spinner.padding" ); padding = UIManager.getInsets( "Spinner.padding" );
MigLayoutVisualPadding.install( spinner );
} }
@Override @Override
@@ -162,8 +160,6 @@ public class FlatSpinnerUI
oldStyleValues = null; oldStyleValues = null;
borderShared = null; borderShared = null;
MigLayoutVisualPadding.uninstall( spinner );
} }
@Override @Override
@@ -173,6 +169,8 @@ public class FlatSpinnerUI
addEditorFocusListener( spinner.getEditor() ); addEditorFocusListener( spinner.getEditor() );
spinner.addFocusListener( getHandler() ); spinner.addFocusListener( getHandler() );
spinner.addPropertyChangeListener( getHandler() ); spinner.addPropertyChangeListener( getHandler() );
MigLayoutVisualPadding.install( spinner );
} }
@Override @Override
@@ -184,6 +182,8 @@ public class FlatSpinnerUI
spinner.removePropertyChangeListener( getHandler() ); spinner.removePropertyChangeListener( getHandler() );
handler = null; handler = null;
MigLayoutVisualPadding.uninstall( spinner );
} }
private Handler getHandler() { private Handler getHandler() {

View File

@@ -174,8 +174,6 @@ public class FlatTextFieldUI
defaultMargin = UIManager.getInsets( prefix + ".margin" ); defaultMargin = UIManager.getInsets( prefix + ".margin" );
LookAndFeel.installProperty( getComponent(), "opaque", false ); LookAndFeel.installProperty( getComponent(), "opaque", false );
MigLayoutVisualPadding.install( getComponent() );
} }
@Override @Override
@@ -193,8 +191,6 @@ public class FlatTextFieldUI
oldStyleValues = null; oldStyleValues = null;
borderShared = null; borderShared = null;
MigLayoutVisualPadding.uninstall( getComponent() );
} }
@Override @Override
@@ -204,6 +200,8 @@ public class FlatTextFieldUI
// necessary to update focus border and background // necessary to update focus border and background
focusListener = new FlatUIUtils.RepaintFocusListener( getComponent(), null ); focusListener = new FlatUIUtils.RepaintFocusListener( getComponent(), null );
getComponent().addFocusListener( focusListener ); getComponent().addFocusListener( focusListener );
MigLayoutVisualPadding.install( getComponent() );
} }
@Override @Override
@@ -217,6 +215,8 @@ public class FlatTextFieldUI
getComponent().getDocument().removeDocumentListener( documentListener ); getComponent().getDocument().removeDocumentListener( documentListener );
documentListener = null; documentListener = null;
} }
MigLayoutVisualPadding.uninstall( getComponent() );
} }
@Override @Override

View File

@@ -125,8 +125,6 @@ public class FlatDatePickerUI
LookAndFeel.installBorder( datePicker, "JXDatePicker.border" ); LookAndFeel.installBorder( datePicker, "JXDatePicker.border" );
LookAndFeel.installProperty( datePicker, "opaque", Boolean.TRUE ); LookAndFeel.installProperty( datePicker, "opaque", Boolean.TRUE );
MigLayoutVisualPadding.install( datePicker );
} }
@Override @Override
@@ -146,6 +144,18 @@ public class FlatDatePickerUI
if( datePicker.getBorder() instanceof UIResource ) if( datePicker.getBorder() instanceof UIResource )
datePicker.setBorder( null ); datePicker.setBorder( null );
}
@Override
protected void installListeners() {
super.installListeners();
MigLayoutVisualPadding.install( datePicker );
}
@Override
protected void uninstallListeners() {
super.uninstallListeners();
MigLayoutVisualPadding.uninstall( datePicker ); MigLayoutVisualPadding.uninstall( datePicker );
} }

View File

@@ -354,14 +354,14 @@ public class FlatSwingXTest
//---- table ---- //---- table ----
table.setModel(new DefaultTableModel( table.setModel(new DefaultTableModel(
new Object[][] { new Object[][] {
{new Date(1574636400000L) /* 25.11.2019, 00:00:00 */}, {new Date(1574636400000L) /* 2019-11-25 */},
{new Date(1517439600000L) /* 01.02.2018, 00:00:00 */}, {new Date(1517439600000L) /* 2018-02-01 */},
}, },
new String[] { new String[] {
"Date" "Date"
} }
) { ) {
Class<?>[] columnTypes = new Class<?>[] { Class<?>[] columnTypes = {
Date.class Date.class
}; };
@Override @Override