Skip to Main Content

How to avoid differences between JLabel and graphics?

quasarusJan 21 2015

I have a question related to the look of elements created with JLabel and drawn using graphics according to the following code:

graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

graphics.setFont(new Font("Arial", Font.PLAIN, 12));

graphics.setColor(Color.BLACK);

g.drawString(text, X, Y);

In the end it appears that there are differences in the look of fonts displayed by JLabel dna graphics. It happens even though the formatting of the text is identical. Is there a way to avoid those differences having in the code both JLabel and graphics?

Thanks,

quasarus

Comments
Post Details
Added on Jan 21 2015
0 comments
444 views