mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 23:37:13 -06:00
TextField and PasswordField: fixed minimum width if focusWidth > 2 and not having a FlatBorder
This commit is contained in:
@@ -116,15 +116,16 @@ public class FlatPasswordFieldUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize( JComponent c ) {
|
public Dimension getPreferredSize( JComponent c ) {
|
||||||
return applyMinimumWidth( super.getPreferredSize( c ) );
|
return applyMinimumWidth( super.getPreferredSize( c ), c );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getMinimumSize( JComponent c ) {
|
public Dimension getMinimumSize( JComponent c ) {
|
||||||
return applyMinimumWidth( super.getMinimumSize( c ) );
|
return applyMinimumWidth( super.getMinimumSize( c ), c );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dimension applyMinimumWidth( Dimension size ) {
|
private Dimension applyMinimumWidth( Dimension size, JComponent c ) {
|
||||||
|
int focusWidth = (c.getBorder() instanceof FlatBorder) ? this.focusWidth : 0;
|
||||||
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ public class FlatTextFieldUI
|
|||||||
(parent != null && parent.getParent() instanceof JSpinner) )
|
(parent != null && parent.getParent() instanceof JSpinner) )
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
|
int focusWidth = (c.getBorder() instanceof FlatBorder) ? this.focusWidth : 0;
|
||||||
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user