mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Button, ComboBox, TextField and DatePicker UI delegates now get Component.focusWidth and Button.arc/Component.arc/TextComponent.arc from component border
This commit is contained in:
@@ -39,7 +39,6 @@ import javax.swing.JToggleButton;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import javax.swing.plaf.basic.BasicButtonListener;
|
||||
@@ -61,8 +60,6 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
*
|
||||
* <!-- FlatButtonUI -->
|
||||
*
|
||||
* @uiDefault Component.focusWidth int
|
||||
* @uiDefault Button.arc int
|
||||
* @uiDefault Button.minimumWidth int
|
||||
* @uiDefault Button.iconTextGap int
|
||||
* @uiDefault Button.startBackground Color optional; if set, a gradient paint is used and Button.background is ignored
|
||||
@@ -92,8 +89,6 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
public class FlatButtonUI
|
||||
extends BasicButtonUI
|
||||
{
|
||||
protected int focusWidth;
|
||||
protected int arc;
|
||||
protected int minimumWidth;
|
||||
protected int iconTextGap;
|
||||
|
||||
@@ -139,8 +134,6 @@ public class FlatButtonUI
|
||||
if( !defaults_initialized ) {
|
||||
String prefix = getPropertyPrefix();
|
||||
|
||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||
arc = UIManager.getInt( "Button.arc" );
|
||||
minimumWidth = UIManager.getInt( prefix + "minimumWidth" );
|
||||
iconTextGap = FlatUIUtils.getUIInt( prefix + "iconTextGap", 4 );
|
||||
|
||||
@@ -187,7 +180,7 @@ public class FlatButtonUI
|
||||
LookAndFeel.installProperty( b, "opaque", false );
|
||||
LookAndFeel.installProperty( b, "iconTextGap", scale( iconTextGap ) );
|
||||
|
||||
MigLayoutVisualPadding.install( b, getFocusWidth( b ) );
|
||||
MigLayoutVisualPadding.install( b );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -279,20 +272,9 @@ public class FlatButtonUI
|
||||
try {
|
||||
FlatUIUtils.setRenderingHints( g2 );
|
||||
|
||||
Border border = c.getBorder();
|
||||
int buttonType = FlatButtonUI.getButtonType( c );
|
||||
boolean isToolBarButton = isToolBarButton( c );
|
||||
float focusWidth = (border instanceof FlatBorder && !isToolBarButton) ? scale( (float) getFocusWidth( c ) ) : 0;
|
||||
float arc;
|
||||
|
||||
if( buttonType == TYPE_SQUARE )
|
||||
arc = 0;
|
||||
else if( buttonType == TYPE_ROUND_RECT )
|
||||
arc = Float.MAX_VALUE;
|
||||
else if( border instanceof FlatButtonBorder || isToolBarButton )
|
||||
arc = scale( (float) this.arc );
|
||||
else
|
||||
arc = 0;
|
||||
float focusWidth = isToolBarButton ? 0 : FlatUIUtils.getBorderFocusWidth( c );
|
||||
float arc = FlatUIUtils.getBorderArc( c );
|
||||
|
||||
boolean def = isDefaultButton( c );
|
||||
|
||||
@@ -426,15 +408,11 @@ public class FlatButtonUI
|
||||
if( isIconOnlyButton( c ) )
|
||||
prefSize.width = Math.max( prefSize.width, prefSize.height );
|
||||
else if( !isToolBarButton( c ) && c.getBorder() instanceof FlatButtonBorder ) {
|
||||
int focusWidth = getFocusWidth( c );
|
||||
prefSize.width = Math.max( prefSize.width, scale( FlatUIUtils.minimumWidth( c, minimumWidth ) + (focusWidth * 2) ) );
|
||||
prefSize.height = Math.max( prefSize.height, scale( FlatUIUtils.minimumHeight( c, 0 ) + (focusWidth * 2) ) );
|
||||
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
|
||||
prefSize.width = Math.max( prefSize.width, scale( FlatUIUtils.minimumWidth( c, minimumWidth ) ) + Math.round( focusWidth * 2 ) );
|
||||
prefSize.height = Math.max( prefSize.height, scale( FlatUIUtils.minimumHeight( c, 0 ) ) + Math.round( focusWidth * 2 ) );
|
||||
}
|
||||
|
||||
return prefSize;
|
||||
}
|
||||
|
||||
protected int getFocusWidth( JComponent c ) {
|
||||
return focusWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +76,6 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
*
|
||||
* <!-- FlatComboBoxUI -->
|
||||
*
|
||||
* @uiDefault Component.focusWidth int
|
||||
* @uiDefault Component.arc int
|
||||
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||
* @uiDefault Component.isIntelliJTheme boolean
|
||||
* @uiDefault Component.borderColor Color
|
||||
@@ -96,8 +94,6 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
public class FlatComboBoxUI
|
||||
extends BasicComboBoxUI
|
||||
{
|
||||
protected int focusWidth;
|
||||
protected int arc;
|
||||
protected String arrowType;
|
||||
protected boolean isIntelliJTheme;
|
||||
protected Color borderColor;
|
||||
@@ -150,8 +146,6 @@ public class FlatComboBoxUI
|
||||
|
||||
LookAndFeel.installProperty( comboBox, "opaque", false );
|
||||
|
||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||
arc = UIManager.getInt( "Component.arc" );
|
||||
arrowType = UIManager.getString( "Component.arrowType" );
|
||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||
borderColor = UIManager.getColor( "Component.borderColor" );
|
||||
@@ -170,7 +164,7 @@ public class FlatComboBoxUI
|
||||
// scale
|
||||
padding = UIScale.scale( padding );
|
||||
|
||||
MigLayoutVisualPadding.install( comboBox, focusWidth );
|
||||
MigLayoutVisualPadding.install( comboBox );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -318,6 +312,9 @@ public class FlatComboBoxUI
|
||||
|
||||
@Override
|
||||
public void update( Graphics g, JComponent c ) {
|
||||
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
|
||||
float arc = FlatUIUtils.getBorderArc( c );
|
||||
|
||||
// fill background if opaque to avoid garbage if user sets opaque to true
|
||||
if( c.isOpaque() && (focusWidth > 0 || arc > 0) )
|
||||
FlatUIUtils.paintParentBackground( g, c );
|
||||
@@ -327,8 +324,6 @@ public class FlatComboBoxUI
|
||||
|
||||
int width = c.getWidth();
|
||||
int height = c.getHeight();
|
||||
float focusWidth = (c.getBorder() instanceof FlatBorder) ? scale( (float) this.focusWidth ) : 0;
|
||||
float arc = (c.getBorder() instanceof FlatRoundBorder) ? scale( (float) this.arc ) : 0;
|
||||
int arrowX = arrowButton.getX();
|
||||
int arrowWidth = arrowButton.getWidth();
|
||||
boolean enabled = comboBox.isEnabled();
|
||||
|
||||
@@ -57,8 +57,6 @@ import com.formdev.flatlaf.FlatClientProperties;
|
||||
*
|
||||
* <!-- FlatPasswordFieldUI -->
|
||||
*
|
||||
* @uiDefault TextComponent.arc int
|
||||
* @uiDefault Component.focusWidth int
|
||||
* @uiDefault Component.minimumWidth int
|
||||
* @uiDefault Component.isIntelliJTheme boolean
|
||||
* @uiDefault PasswordField.placeholderForeground Color
|
||||
@@ -70,8 +68,6 @@ import com.formdev.flatlaf.FlatClientProperties;
|
||||
public class FlatPasswordFieldUI
|
||||
extends BasicPasswordFieldUI
|
||||
{
|
||||
protected int arc;
|
||||
protected int focusWidth;
|
||||
protected int minimumWidth;
|
||||
protected boolean isIntelliJTheme;
|
||||
protected Color placeholderForeground;
|
||||
@@ -89,8 +85,6 @@ public class FlatPasswordFieldUI
|
||||
super.installDefaults();
|
||||
|
||||
String prefix = getPropertyPrefix();
|
||||
arc = UIManager.getInt( "TextComponent.arc" );
|
||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||
placeholderForeground = UIManager.getColor( prefix + ".placeholderForeground" );
|
||||
@@ -98,7 +92,7 @@ public class FlatPasswordFieldUI
|
||||
|
||||
LookAndFeel.installProperty( getComponent(), "opaque", false );
|
||||
|
||||
MigLayoutVisualPadding.install( getComponent(), focusWidth );
|
||||
MigLayoutVisualPadding.install( getComponent() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,7 +154,7 @@ public class FlatPasswordFieldUI
|
||||
|
||||
@Override
|
||||
protected void paintSafely( Graphics g ) {
|
||||
FlatTextFieldUI.paintBackground( g, getComponent(), focusWidth, arc, isIntelliJTheme );
|
||||
FlatTextFieldUI.paintBackground( g, getComponent(), isIntelliJTheme );
|
||||
FlatTextFieldUI.paintPlaceholder( g, getComponent(), placeholderForeground );
|
||||
paintCapsLock( g );
|
||||
super.paintSafely( g );
|
||||
@@ -194,8 +188,8 @@ public class FlatPasswordFieldUI
|
||||
|
||||
private Dimension applyMinimumWidth( Dimension size, JComponent c ) {
|
||||
int minimumWidth = FlatUIUtils.minimumWidth( getComponent(), this.minimumWidth );
|
||||
int focusWidth = (c.getBorder() instanceof FlatBorder) ? this.focusWidth : 0;
|
||||
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
||||
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
|
||||
size.width = Math.max( size.width, scale( minimumWidth ) + Math.round( focusWidth * 2 ) );
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class FlatScrollPaneUI
|
||||
int focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||
LookAndFeel.installProperty( c, "opaque", focusWidth == 0 );
|
||||
|
||||
MigLayoutVisualPadding.install( scrollpane, focusWidth );
|
||||
MigLayoutVisualPadding.install( scrollpane );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,8 +56,6 @@ import javax.swing.plaf.basic.BasicSpinnerUI;
|
||||
*
|
||||
* <!-- FlatSpinnerUI -->
|
||||
*
|
||||
* @uiDefault Component.focusWidth int
|
||||
* @uiDefault Component.arc int
|
||||
* @uiDefault Component.minimumWidth int
|
||||
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||
* @uiDefault Component.isIntelliJTheme boolean
|
||||
@@ -78,8 +76,6 @@ public class FlatSpinnerUI
|
||||
{
|
||||
private Handler handler;
|
||||
|
||||
protected int focusWidth;
|
||||
protected int arc;
|
||||
protected int minimumWidth;
|
||||
protected String arrowType;
|
||||
protected boolean isIntelliJTheme;
|
||||
@@ -103,8 +99,6 @@ public class FlatSpinnerUI
|
||||
|
||||
LookAndFeel.installProperty( spinner, "opaque", false );
|
||||
|
||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||
arc = UIManager.getInt( "Component.arc" );
|
||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||
arrowType = UIManager.getString( "Component.arrowType" );
|
||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||
@@ -121,7 +115,7 @@ public class FlatSpinnerUI
|
||||
// scale
|
||||
padding = scale( padding );
|
||||
|
||||
MigLayoutVisualPadding.install( spinner, focusWidth );
|
||||
MigLayoutVisualPadding.install( spinner );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -246,8 +240,11 @@ public class FlatSpinnerUI
|
||||
|
||||
@Override
|
||||
public void update( Graphics g, JComponent c ) {
|
||||
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
|
||||
float arc = FlatUIUtils.getBorderArc( c );
|
||||
|
||||
// fill background if opaque to avoid garbage if user sets opaque to true
|
||||
if( c.isOpaque() && (focusWidth > 0 || arc != 0) )
|
||||
if( c.isOpaque() && (focusWidth > 0 || arc > 0) )
|
||||
FlatUIUtils.paintParentBackground( g, c );
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
@@ -255,8 +252,6 @@ public class FlatSpinnerUI
|
||||
|
||||
int width = c.getWidth();
|
||||
int height = c.getHeight();
|
||||
float focusWidth = (c.getBorder() instanceof FlatBorder) ? scale( (float) this.focusWidth ) : 0;
|
||||
float arc = (c.getBorder() instanceof FlatRoundBorder) ? scale( (float) this.arc ) : 0;
|
||||
Component nextButton = getHandler().nextButton;
|
||||
int arrowX = nextButton.getX();
|
||||
int arrowWidth = nextButton.getWidth();
|
||||
@@ -328,8 +323,9 @@ public class FlatSpinnerUI
|
||||
// the arrows width is the same as the inner height so that the arrows area is square
|
||||
int minimumWidth = FlatUIUtils.minimumWidth( spinner, FlatSpinnerUI.this.minimumWidth );
|
||||
int innerHeight = editorSize.height + padding.top + padding.bottom;
|
||||
float focusWidth = FlatUIUtils.getBorderFocusWidth( spinner );
|
||||
return new Dimension(
|
||||
Math.max( insets.left + insets.right + editorSize.width + padding.left + padding.right + innerHeight, scale( minimumWidth + (focusWidth * 2) ) ),
|
||||
Math.max( insets.left + insets.right + editorSize.width + padding.left + padding.right + innerHeight, scale( minimumWidth ) + Math.round( focusWidth * 2 ) ),
|
||||
insets.top + insets.bottom + innerHeight );
|
||||
}
|
||||
|
||||
|
||||
@@ -60,8 +60,6 @@ import com.formdev.flatlaf.FlatClientProperties;
|
||||
*
|
||||
* <!-- FlatTextFieldUI -->
|
||||
*
|
||||
* @uiDefault TextComponent.arc int
|
||||
* @uiDefault Component.focusWidth int
|
||||
* @uiDefault Component.minimumWidth int
|
||||
* @uiDefault Component.isIntelliJTheme boolean
|
||||
* @uiDefault TextField.placeholderForeground Color
|
||||
@@ -72,8 +70,6 @@ import com.formdev.flatlaf.FlatClientProperties;
|
||||
public class FlatTextFieldUI
|
||||
extends BasicTextFieldUI
|
||||
{
|
||||
protected int arc;
|
||||
protected int focusWidth;
|
||||
protected int minimumWidth;
|
||||
protected boolean isIntelliJTheme;
|
||||
protected Color placeholderForeground;
|
||||
@@ -89,15 +85,13 @@ public class FlatTextFieldUI
|
||||
super.installDefaults();
|
||||
|
||||
String prefix = getPropertyPrefix();
|
||||
arc = UIManager.getInt( "TextComponent.arc" );
|
||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||
placeholderForeground = UIManager.getColor( prefix + ".placeholderForeground" );
|
||||
|
||||
LookAndFeel.installProperty( getComponent(), "opaque", false );
|
||||
|
||||
MigLayoutVisualPadding.install( getComponent(), focusWidth );
|
||||
MigLayoutVisualPadding.install( getComponent() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,7 +134,7 @@ public class FlatTextFieldUI
|
||||
|
||||
@Override
|
||||
protected void paintSafely( Graphics g ) {
|
||||
paintBackground( g, getComponent(), focusWidth, arc, isIntelliJTheme );
|
||||
paintBackground( g, getComponent(), isIntelliJTheme );
|
||||
paintPlaceholder( g, getComponent(), placeholderForeground );
|
||||
super.paintSafely( g );
|
||||
}
|
||||
@@ -150,7 +144,7 @@ public class FlatTextFieldUI
|
||||
// background is painted elsewhere
|
||||
}
|
||||
|
||||
static void paintBackground( Graphics g, JTextComponent c, int focusWidth, int arc, boolean isIntelliJTheme ) {
|
||||
static void paintBackground( Graphics g, JTextComponent c, boolean isIntelliJTheme ) {
|
||||
Border border = c.getBorder();
|
||||
|
||||
// do not paint background if:
|
||||
@@ -161,6 +155,9 @@ public class FlatTextFieldUI
|
||||
if( !c.isOpaque() && !(border instanceof FlatBorder) && FlatUIUtils.hasOpaqueBeenExplicitlySet( c ) )
|
||||
return;
|
||||
|
||||
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
|
||||
float arc = FlatUIUtils.getBorderArc( c );
|
||||
|
||||
// fill background if opaque to avoid garbage if user sets opaque to true
|
||||
if( c.isOpaque() && (focusWidth > 0 || arc > 0) )
|
||||
FlatUIUtils.paintParentBackground( g, c );
|
||||
@@ -170,16 +167,13 @@ public class FlatTextFieldUI
|
||||
try {
|
||||
FlatUIUtils.setRenderingHints( g2 );
|
||||
|
||||
float fFocusWidth = (border instanceof FlatBorder) ? scale( (float) focusWidth ) : 0;
|
||||
float fArc = (border instanceof FlatTextBorder) ? scale( (float) arc ) : 0;
|
||||
|
||||
Color background = c.getBackground();
|
||||
g2.setColor( !(background instanceof UIResource)
|
||||
? background
|
||||
: (isIntelliJTheme && (!c.isEnabled() || !c.isEditable())
|
||||
? FlatUIUtils.getParentBackground( c )
|
||||
: background) );
|
||||
FlatUIUtils.paintComponentBackground( g2, 0, 0, c.getWidth(), c.getHeight(), fFocusWidth, fArc );
|
||||
FlatUIUtils.paintComponentBackground( g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, arc );
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
@@ -232,8 +226,8 @@ public class FlatTextFieldUI
|
||||
return size;
|
||||
|
||||
int minimumWidth = FlatUIUtils.minimumWidth( getComponent(), this.minimumWidth );
|
||||
int focusWidth = (c.getBorder() instanceof FlatBorder) ? this.focusWidth : 0;
|
||||
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
||||
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
|
||||
size.width = Math.max( size.width, scale( minimumWidth ) + Math.round( focusWidth * 2 ) );
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class FlatToggleButtonUI
|
||||
case BUTTON_TYPE:
|
||||
if( BUTTON_TYPE_TAB.equals( e.getOldValue() ) || BUTTON_TYPE_TAB.equals( e.getNewValue() ) ) {
|
||||
MigLayoutVisualPadding.uninstall( b );
|
||||
MigLayoutVisualPadding.install( b, getFocusWidth( b ) );
|
||||
MigLayoutVisualPadding.install( b );
|
||||
b.revalidate();
|
||||
}
|
||||
|
||||
@@ -212,9 +212,4 @@ public class FlatToggleButtonUI
|
||||
|
||||
return super.getForeground( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getFocusWidth( JComponent c ) {
|
||||
return isTabButton( c ) ? 0 : super.getFocusWidth( c );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import java.util.function.Consumer;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import com.formdev.flatlaf.util.DerivedColor;
|
||||
@@ -142,6 +143,26 @@ public class FlatUIUtils
|
||||
return (KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner() == c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scaled thickness of the outer focus border for the given component.
|
||||
*/
|
||||
public static float getBorderFocusWidth( JComponent c ) {
|
||||
Border border = c.getBorder();
|
||||
return (border instanceof FlatBorder)
|
||||
? UIScale.scale( (float) ((FlatBorder)border).getFocusWidth( c ) )
|
||||
: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scaled arc diameter of the border for the given component.
|
||||
*/
|
||||
public static float getBorderArc( JComponent c ) {
|
||||
Border border = c.getBorder();
|
||||
return (border instanceof FlatBorder)
|
||||
? UIScale.scale( (float) ((FlatBorder)border).getArc( c ) )
|
||||
: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets rendering hints used for painting.
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.awt.Insets;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.function.Function;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.border.Border;
|
||||
|
||||
/**
|
||||
* Support for MigLayout visual paddings.
|
||||
@@ -69,14 +70,17 @@ public class MigLayoutVisualPadding
|
||||
/**
|
||||
* Convenience method that checks whether component border is a FlatBorder.
|
||||
*/
|
||||
public static void install( JComponent c, int focusWidth ) {
|
||||
public static void install( JComponent c ) {
|
||||
if( !migLayoutAvailable )
|
||||
return;
|
||||
|
||||
install( c, c2 -> {
|
||||
return (c2.getBorder() instanceof FlatBorder)
|
||||
? new Insets( focusWidth, focusWidth, focusWidth, focusWidth )
|
||||
: null;
|
||||
Border border = c2.getBorder();
|
||||
if( border instanceof FlatBorder ) {
|
||||
int focusWidth = ((FlatBorder)border).getFocusWidth( c2 );
|
||||
return new Insets( focusWidth, focusWidth, focusWidth, focusWidth );
|
||||
} else
|
||||
return null;
|
||||
}, "border" );
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,6 @@ import org.jdesktop.swingx.JXPanel;
|
||||
import org.jdesktop.swingx.calendar.DatePickerFormatter.DatePickerFormatterUIResource;
|
||||
import org.jdesktop.swingx.plaf.basic.BasicDatePickerUI;
|
||||
import com.formdev.flatlaf.ui.FlatArrowButton;
|
||||
import com.formdev.flatlaf.ui.FlatBorder;
|
||||
import com.formdev.flatlaf.ui.FlatRoundBorder;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.ui.MigLayoutVisualPadding;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
@@ -62,8 +60,6 @@ public class FlatDatePickerUI
|
||||
{
|
||||
protected Insets padding;
|
||||
|
||||
protected int focusWidth;
|
||||
protected int arc;
|
||||
protected String arrowType;
|
||||
protected Color borderColor;
|
||||
protected Color disabledBorderColor;
|
||||
@@ -88,8 +84,6 @@ public class FlatDatePickerUI
|
||||
|
||||
padding = UIManager.getInsets( "ComboBox.padding" );
|
||||
|
||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||
arc = UIManager.getInt( "Component.arc" );
|
||||
arrowType = UIManager.getString( "Component.arrowType" );
|
||||
borderColor = UIManager.getColor( "Component.borderColor" );
|
||||
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
||||
@@ -130,7 +124,7 @@ public class FlatDatePickerUI
|
||||
LookAndFeel.installBorder( datePicker, "JXDatePicker.border" );
|
||||
LookAndFeel.installProperty( datePicker, "opaque", Boolean.TRUE );
|
||||
|
||||
MigLayoutVisualPadding.install( datePicker, focusWidth );
|
||||
MigLayoutVisualPadding.install( datePicker );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,8 +222,8 @@ public class FlatDatePickerUI
|
||||
|
||||
int width = c.getWidth();
|
||||
int height = c.getHeight();
|
||||
float focusWidth = (c.getBorder() instanceof FlatBorder) ? scale( (float) this.focusWidth ) : 0;
|
||||
float arc = (c.getBorder() instanceof FlatRoundBorder) ? scale( (float) this.arc ) : 0;
|
||||
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
|
||||
float arc = FlatUIUtils.getBorderArc( c );
|
||||
int arrowX = popupButton.getX();
|
||||
int arrowWidth = popupButton.getWidth();
|
||||
boolean enabled = c.isEnabled();
|
||||
|
||||
@@ -83,8 +83,6 @@ public class FlatComponentsTest
|
||||
JButton button15 = new JButton();
|
||||
JButton button16 = new JButton();
|
||||
JButton button20 = new JButton();
|
||||
JButton button24 = new JButton();
|
||||
JButton button25 = new JButton();
|
||||
JLabel toggleButtonLabel = new JLabel();
|
||||
JToggleButton toggleButton1 = new JToggleButton();
|
||||
JToggleButton toggleButton9 = new JToggleButton();
|
||||
@@ -99,8 +97,6 @@ public class FlatComponentsTest
|
||||
JToggleButton toggleButton13 = new JToggleButton();
|
||||
JToggleButton toggleButton14 = new JToggleButton();
|
||||
JToggleButton toggleButton18 = new JToggleButton();
|
||||
JToggleButton toggleButton21 = new JToggleButton();
|
||||
JToggleButton toggleButton22 = new JToggleButton();
|
||||
JLabel checkBoxLabel = new JLabel();
|
||||
JCheckBox checkBox1 = new JCheckBox();
|
||||
JCheckBox checkBox2 = new JCheckBox();
|
||||
@@ -375,18 +371,6 @@ public class FlatComponentsTest
|
||||
button20.setBorder(BorderFactory.createEmptyBorder());
|
||||
add(button20, "cell 6 1");
|
||||
|
||||
//---- button24 ----
|
||||
button24.setText("sq");
|
||||
button24.setBorder(BorderFactory.createEmptyBorder());
|
||||
button24.putClientProperty("JButton.buttonType", "square");
|
||||
add(button24, "cell 6 1");
|
||||
|
||||
//---- button25 ----
|
||||
button25.setText("rd");
|
||||
button25.setBorder(new EmptyBorder(0, 10, 0, 10));
|
||||
button25.putClientProperty("JButton.buttonType", "roundRect");
|
||||
add(button25, "cell 6 1");
|
||||
|
||||
//---- toggleButtonLabel ----
|
||||
toggleButtonLabel.setText("JToggleButton:");
|
||||
add(toggleButtonLabel, "cell 0 2");
|
||||
@@ -458,18 +442,6 @@ public class FlatComponentsTest
|
||||
toggleButton18.setBorder(BorderFactory.createEmptyBorder());
|
||||
add(toggleButton18, "cell 6 2");
|
||||
|
||||
//---- toggleButton21 ----
|
||||
toggleButton21.setText("sq");
|
||||
toggleButton21.setBorder(BorderFactory.createEmptyBorder());
|
||||
toggleButton21.putClientProperty("JButton.buttonType", "square");
|
||||
add(toggleButton21, "cell 6 2");
|
||||
|
||||
//---- toggleButton22 ----
|
||||
toggleButton22.setText("rd");
|
||||
toggleButton22.setBorder(new EmptyBorder(0, 10, 0, 10));
|
||||
toggleButton22.putClientProperty("JButton.buttonType", "roundRect");
|
||||
add(toggleButton22, "cell 6 2");
|
||||
|
||||
//---- checkBoxLabel ----
|
||||
checkBoxLabel.setText("JCheckBox");
|
||||
add(checkBoxLabel, "cell 0 3");
|
||||
|
||||
@@ -144,22 +144,6 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 6 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "button24"
|
||||
"text": "sq"
|
||||
"border": #EmptyBorder0
|
||||
"$client.JButton.buttonType": "square"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 6 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "button25"
|
||||
"text": "rd"
|
||||
"border": &EmptyBorder1 new javax.swing.border.EmptyBorder( 0, 10, 0, 10 )
|
||||
"$client.JButton.buttonType": "roundRect"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 6 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "toggleButtonLabel"
|
||||
"text": "JToggleButton:"
|
||||
@@ -259,22 +243,6 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 6 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton21"
|
||||
"text": "sq"
|
||||
"border": #EmptyBorder0
|
||||
"$client.JButton.buttonType": "square"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 6 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton22"
|
||||
"text": "rd"
|
||||
"border": #EmptyBorder1
|
||||
"$client.JButton.buttonType": "roundRect"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 6 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "checkBoxLabel"
|
||||
"text": "JCheckBox"
|
||||
|
||||
Reference in New Issue
Block a user