mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
Buttons: made iconTextGap configurable in properties files and scale it
This commit is contained in:
@@ -31,6 +31,7 @@ import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
@@ -44,6 +45,7 @@ import javax.swing.plaf.basic.BasicButtonUI;
|
||||
* @uiDefault Component.focusWidth int
|
||||
* @uiDefault Button.arc int
|
||||
* @uiDefault Button.minimumWidth int
|
||||
* @uiDefault Button.iconTextGap int
|
||||
* @uiDefault Button.focusedBackground Color optional
|
||||
* @uiDefault Button.hoverBackground Color optional
|
||||
* @uiDefault Button.pressedBackground Color optional
|
||||
@@ -64,6 +66,7 @@ public class FlatButtonUI
|
||||
protected int focusWidth;
|
||||
protected int arc;
|
||||
protected int minimumWidth;
|
||||
protected int iconTextGap;
|
||||
|
||||
protected Color focusedBackground;
|
||||
protected Color hoverBackground;
|
||||
@@ -101,6 +104,7 @@ public class FlatButtonUI
|
||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||
arc = UIManager.getInt( prefix + "arc" );
|
||||
minimumWidth = UIManager.getInt( prefix + "minimumWidth" );
|
||||
iconTextGap = FlatUIUtils.getUIInt( prefix + "iconTextGap", 4 );
|
||||
|
||||
focusedBackground = UIManager.getColor( prefix + "focusedBackground" );
|
||||
hoverBackground = UIManager.getColor( prefix + "hoverBackground" );
|
||||
@@ -121,6 +125,8 @@ public class FlatButtonUI
|
||||
defaults_initialized = true;
|
||||
}
|
||||
|
||||
LookAndFeel.installProperty( b, "iconTextGap", scale( iconTextGap ) );
|
||||
|
||||
MigLayoutVisualPadding.install( b, focusWidth );
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,13 @@
|
||||
|
||||
package com.formdev.flatlaf.ui;
|
||||
|
||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicRadioButtonUI;
|
||||
@@ -30,6 +32,7 @@ import javax.swing.plaf.basic.BasicRadioButtonUI;
|
||||
*
|
||||
* TODO document used UI defaults of superclass
|
||||
*
|
||||
* @uiDefault Button.iconTextGap int
|
||||
* @uiDefault Button.disabledText Color
|
||||
*
|
||||
* @author Karl Tauber
|
||||
@@ -37,6 +40,7 @@ import javax.swing.plaf.basic.BasicRadioButtonUI;
|
||||
public class FlatRadioButtonUI
|
||||
extends BasicRadioButtonUI
|
||||
{
|
||||
protected int iconTextGap;
|
||||
protected Color disabledText;
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
@@ -56,11 +60,14 @@ public class FlatRadioButtonUI
|
||||
if( !defaults_initialized ) {
|
||||
String prefix = getPropertyPrefix();
|
||||
|
||||
iconTextGap = FlatUIUtils.getUIInt( prefix + "iconTextGap", 4 );
|
||||
disabledText = UIManager.getColor( prefix + "disabledText" );
|
||||
|
||||
defaults_initialized = true;
|
||||
}
|
||||
|
||||
LookAndFeel.installProperty( b, "iconTextGap", scale( iconTextGap ) );
|
||||
|
||||
MigLayoutVisualPadding.install( b, null );
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ Button.border=com.formdev.flatlaf.ui.FlatButtonBorder
|
||||
Button.arc=6
|
||||
Button.minimumWidth=72
|
||||
Button.margin=2,14,2,14
|
||||
Button.iconTextGap=4
|
||||
Button.rollover=true
|
||||
Button.defaultButtonFollowsFocus=false
|
||||
|
||||
@@ -75,6 +76,7 @@ Button.defaultButtonFollowsFocus=false
|
||||
CheckBox.border=com.formdev.flatlaf.ui.FlatMarginBorder
|
||||
CheckBox.icon=com.formdev.flatlaf.icons.FlatCheckBoxIcon
|
||||
CheckBox.margin=2,2,2,2
|
||||
CheckBox.iconTextGap=4
|
||||
CheckBox.rollover=true
|
||||
|
||||
|
||||
@@ -249,6 +251,7 @@ RadioButton.border=com.formdev.flatlaf.ui.FlatMarginBorder
|
||||
RadioButton.icon=com.formdev.flatlaf.icons.FlatRadioButtonIcon
|
||||
RadioButton.icon.centerDiameter=8
|
||||
RadioButton.margin=2,2,2,2
|
||||
RadioButton.iconTextGap=4
|
||||
RadioButton.rollover=true
|
||||
|
||||
|
||||
@@ -373,6 +376,7 @@ TitledBorder.border=1,1,1,1,@@Separator.foreground
|
||||
ToggleButton.border=com.formdev.flatlaf.ui.FlatButtonBorder
|
||||
ToggleButton.arc=6
|
||||
ToggleButton.margin=2,14,2,14
|
||||
ToggleButton.iconTextGap=4
|
||||
ToggleButton.rollover=true
|
||||
|
||||
ToggleButton.background=@@Button.background
|
||||
|
||||
Reference in New Issue
Block a user