PasswordField: paint caps lock icon on left side in right-to-left component orientation

This commit is contained in:
Karl Tauber
2021-07-09 15:14:29 +02:00
parent cc6d3c1b1a
commit 0b342acec9
2 changed files with 8 additions and 2 deletions

View File

@@ -177,7 +177,9 @@ public class FlatPasswordFieldUI
JTextComponent c = getComponent();
int y = (c.getHeight() - capsLockIcon.getIconHeight()) / 2;
int x = c.getWidth() - capsLockIcon.getIconWidth() - y;
int x = c.getComponentOrientation().isLeftToRight()
? c.getWidth() - capsLockIcon.getIconWidth() - y
: y;
capsLockIcon.paintIcon( c, g, x, y );
}
@@ -202,6 +204,8 @@ public class FlatPasswordFieldUI
if( !isCapsLockVisible() )
return padding;
return FlatUIUtils.addInsets( padding, new Insets( 0, 0, 0, capsLockIcon.getIconWidth() ) );
boolean ltr = getComponent().getComponentOrientation().isLeftToRight();
int iconWidth = capsLockIcon.getIconWidth();
return FlatUIUtils.addInsets( padding, new Insets( 0, ltr ? 0 : iconWidth, 0, ltr ? iconWidth : 0 ) );
}
}