tomkpunkt
tomkpunkt

Reputation: 1403

Why different font rendering with graphics.drawString() and a default JLabel with ClearType?

Why has the displayed GUI different font style/rendering with graphics.drawString() and a default JLabel with activated cleartype? And how can i fix it?

Image to show the differents

Upvotes: 5

Views: 2940

Answers (1)

Nour E Ghtami
Nour E Ghtami

Reputation: 66

Try this

Graphics2D g2d = (Graphics2D)g;    
Font font = new Font("Arial", Font.PLAIN, 12);

g2d.setFont(font);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawString("Hello World", 25, 100);

Upvotes: 5

Related Questions