mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
TextField, FormattedTextField, PasswordField and ComboBox: fixed alignment of placeholder text in right-to-left component orientation
This commit is contained in:
@@ -17,6 +17,8 @@ FlatLaf Change Log
|
|||||||
since FlatLaf 1.3)
|
since FlatLaf 1.3)
|
||||||
- OptionPane: Fixed `OptionPane.sameSizeButtons`, which did not work as expected
|
- OptionPane: Fixed `OptionPane.sameSizeButtons`, which did not work as expected
|
||||||
when setting to `false`.
|
when setting to `false`.
|
||||||
|
- TextField, FormattedTextField, PasswordField and ComboBox: Fixed alignment of
|
||||||
|
placeholder text in right-to-left component orientation.
|
||||||
|
|
||||||
|
|
||||||
## 1.5
|
## 1.5
|
||||||
|
|||||||
@@ -237,12 +237,13 @@ public class FlatTextFieldUI
|
|||||||
// compute placeholder location
|
// compute placeholder location
|
||||||
Rectangle r = getVisibleEditorRect();
|
Rectangle r = getVisibleEditorRect();
|
||||||
FontMetrics fm = c.getFontMetrics( c.getFont() );
|
FontMetrics fm = c.getFontMetrics( c.getFont() );
|
||||||
|
String clippedPlaceholder = JavaCompatibility.getClippedString( c, fm, (String) placeholder, r.width );
|
||||||
|
int x = r.x + (c.getComponentOrientation().isLeftToRight() ? 0 : r.width - fm.stringWidth( clippedPlaceholder ));
|
||||||
int y = r.y + fm.getAscent() + ((r.height - fm.getHeight()) / 2);
|
int y = r.y + fm.getAscent() + ((r.height - fm.getHeight()) / 2);
|
||||||
|
|
||||||
// paint placeholder
|
// paint placeholder
|
||||||
g.setColor( placeholderForeground );
|
g.setColor( placeholderForeground );
|
||||||
String clippedPlaceholder = JavaCompatibility.getClippedString( c, fm, (String) placeholder, r.width );
|
FlatUIUtils.drawString( c, g, clippedPlaceholder, x, y );
|
||||||
FlatUIUtils.drawString( c, g, clippedPlaceholder, r.x, y );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user