Menus: scale defaultTextIconGap again if iconTextGap property has changed

This commit is contained in:
Karl Tauber
2019-09-15 23:50:45 +02:00
parent b4b914de52
commit 90af8c0ce8
4 changed files with 56 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
package com.formdev.flatlaf.ui;
import static com.formdev.flatlaf.util.UIScale.scale;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI;
@@ -40,4 +41,17 @@ public class FlatCheckBoxMenuItemUI
// scale
defaultTextIconGap = scale( defaultTextIconGap );
}
/**
* Scale defaultTextIconGap again if iconTextGap property has changed.
*/
@Override
protected PropertyChangeListener createPropertyChangeListener( JComponent c ) {
PropertyChangeListener superListener = super.createPropertyChangeListener( c );
return e -> {
superListener.propertyChange( e );
if( e.getPropertyName() == "iconTextGap" )
defaultTextIconGap = scale( defaultTextIconGap );
};
}
}

View File

@@ -17,6 +17,7 @@
package com.formdev.flatlaf.ui;
import static com.formdev.flatlaf.util.UIScale.scale;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicMenuItemUI;
@@ -40,4 +41,17 @@ public class FlatMenuItemUI
// scale
defaultTextIconGap = scale( defaultTextIconGap );
}
/**
* Scale defaultTextIconGap again if iconTextGap property has changed.
*/
@Override
protected PropertyChangeListener createPropertyChangeListener( JComponent c ) {
PropertyChangeListener superListener = super.createPropertyChangeListener( c );
return e -> {
superListener.propertyChange( e );
if( e.getPropertyName() == "iconTextGap" )
defaultTextIconGap = scale( defaultTextIconGap );
};
}
}

View File

@@ -17,6 +17,7 @@
package com.formdev.flatlaf.ui;
import static com.formdev.flatlaf.util.UIScale.scale;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicMenuUI;
@@ -40,4 +41,17 @@ public class FlatMenuUI
// scale
defaultTextIconGap = scale( defaultTextIconGap );
}
/**
* Scale defaultTextIconGap again if iconTextGap property has changed.
*/
@Override
protected PropertyChangeListener createPropertyChangeListener( JComponent c ) {
PropertyChangeListener superListener = super.createPropertyChangeListener( c );
return e -> {
superListener.propertyChange( e );
if( e.getPropertyName() == "iconTextGap" )
defaultTextIconGap = scale( defaultTextIconGap );
};
}
}

View File

@@ -17,6 +17,7 @@
package com.formdev.flatlaf.ui;
import static com.formdev.flatlaf.util.UIScale.scale;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicRadioButtonMenuItemUI;
@@ -40,4 +41,17 @@ public class FlatRadioButtonMenuItemUI
// scale
defaultTextIconGap = scale( defaultTextIconGap );
}
/**
* Scale defaultTextIconGap again if iconTextGap property has changed.
*/
@Override
protected PropertyChangeListener createPropertyChangeListener( JComponent c ) {
PropertyChangeListener superListener = super.createPropertyChangeListener( c );
return e -> {
superListener.propertyChange( e );
if( e.getPropertyName() == "iconTextGap" )
defaultTextIconGap = scale( defaultTextIconGap );
};
}
}