Skip to content

Commit

Permalink
TextField now honours right component inset
Browse files Browse the repository at this point in the history
If the placeholder can't be drawn fully, we clip it by adding an
ellipse.
  • Loading branch information
Blanco27 committed Dec 23, 2020
1 parent 073a25f commit 9e49402
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import javax.swing.text.JTextComponent;
import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.util.HiDPIUtils;
import com.formdev.flatlaf.util.JavaCompatibility;

/**
* Provides the Flat LaF UI delegate for {@link javax.swing.JTextField}.
Expand Down Expand Up @@ -213,7 +214,9 @@ static void paintPlaceholder( Graphics g, JTextComponent c, Color placeholderFor

// paint placeholder
g.setColor( placeholderForeground );
FlatUIUtils.drawString( c, g, (String) placeholder, x, y );
String clippedPlaceholder = JavaCompatibility.getClippedString( jc, fm,
(String) placeholder, c.getWidth() - insets.left - insets.right );
FlatUIUtils.drawString( c, g, clippedPlaceholder, x, y );
}

@Override
Expand Down

0 comments on commit 9e49402

Please sign in to comment.