TextField and PasswordField: fixed minimum width if focusWidth > 2 and not having a FlatBorder

This commit is contained in:
Karl Tauber
2019-10-20 22:17:15 +02:00
parent 0853a1aa2e
commit 714c6e2920
2 changed files with 5 additions and 3 deletions

View File

@@ -116,15 +116,16 @@ public class FlatPasswordFieldUI
@Override
public Dimension getPreferredSize( JComponent c ) {
return applyMinimumWidth( super.getPreferredSize( c ) );
return applyMinimumWidth( super.getPreferredSize( c ), c );
}
@Override
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) ) );
return size;
}

View File

@@ -128,6 +128,7 @@ public class FlatTextFieldUI
(parent != null && parent.getParent() instanceof JSpinner) )
return size;
int focusWidth = (c.getBorder() instanceof FlatBorder) ? this.focusWidth : 0;
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
return size;
}