How to enable anti-aliasing for JavaFX TextField text?

Diamond Block :

I have a TextField and a Text object. Both use the exact same font, but for the Text object there is a method that can be used to smooth the font: .setFontSmoothingType(). However, no such method exists for TextField.

As Shaw pointed out, Text objects by default smooth the font, but this is not the case for TextFields.

This difference is unfortunately noticeable as seen in this screenshot:

enter image description here

The top is the TextField and the bottom is the Text with smoothing. So how would I smooth the font for the TextField?

Any help is appreciated, thanks!

Diamond Block :

I was finally able to solve this problem! Using Scene Builder's CSS Analyzer, I was able to find a property called -fx-font-smoothing-type under .text-field .text. By changing the value to gray, the text in the TextField will become smoothed!

Here's an updated screenshot.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=105391&siteId=1