Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 18 2015
Added on Jan 21 2015
0 comments
513 views