Skip to content

Commit

Permalink
TextField and PasswordField: fixed minimum width if focusWidth > 2 an…
Browse files Browse the repository at this point in the history
…d not having a FlatBorder
  • Loading branch information
DevCharly committed Oct 20, 2019
1 parent 0853a1a commit 714c6e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,16 @@ protected void paintBackground( Graphics g ) {

@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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private Dimension applyMinimumWidth( Dimension size, JComponent c ) {
(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;
}
Expand Down

0 comments on commit 714c6e2

Please sign in to comment.