mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
TextField: consider widths of leading and trailing icons for minimum/preferred text field size
This commit is contained in:
@@ -81,9 +81,12 @@ public class FlatTextFieldUI
|
|||||||
protected boolean isIntelliJTheme;
|
protected boolean isIntelliJTheme;
|
||||||
protected Color placeholderForeground;
|
protected Color placeholderForeground;
|
||||||
protected Color focusedBackground;
|
protected Color focusedBackground;
|
||||||
|
/** @since 2 */
|
||||||
protected int iconTextGap;
|
protected int iconTextGap;
|
||||||
|
|
||||||
|
/** @since 2 */
|
||||||
protected Icon leadingIcon;
|
protected Icon leadingIcon;
|
||||||
|
/** @since 2 */
|
||||||
protected Icon trailingIcon;
|
protected Icon trailingIcon;
|
||||||
|
|
||||||
private Insets defaultMargin;
|
private Insets defaultMargin;
|
||||||
@@ -323,12 +326,19 @@ debug*/
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize( JComponent c ) {
|
public Dimension getPreferredSize( JComponent c ) {
|
||||||
return applyMinimumWidth( c, super.getPreferredSize( c ), minimumWidth );
|
return applyMinimumWidth( c, applyExtraSize( super.getPreferredSize( c ) ), minimumWidth );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getMinimumSize( JComponent c ) {
|
public Dimension getMinimumSize( JComponent c ) {
|
||||||
return applyMinimumWidth( c, super.getMinimumSize( c ), minimumWidth );
|
return applyMinimumWidth( c, applyExtraSize( super.getMinimumSize( c ) ), minimumWidth );
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dimension applyExtraSize( Dimension size ) {
|
||||||
|
// add width of leading and trailing icons
|
||||||
|
size.width += getLeadingIconWidth() + getTrailingIconWidth();
|
||||||
|
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dimension applyMinimumWidth( JComponent c, Dimension size, int minimumWidth ) {
|
private Dimension applyMinimumWidth( JComponent c, Dimension size, int minimumWidth ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user