ledd
ledd

Reputation: 23

My labels are blurry in Java

I am writing an application with small fonts in JLabels meant to be displayed on large low res screens.

I create a JLablel using this code, the JFrame has white background.

JLabel myJlabel=new JLabel();
myJlabel.setFont(new Font("Terminal",0,8));
myJlabel.setForeground(Color.black);
myJlabel.setText("Hamburger");

But it looks blurry. The image blow illustrates my problem. On the left it is from a screenshot of my application and on the right it is from the Notapad.exe with the same font and size. One if blurry and on is not.

enter image description here

Here is the images again enlarged and re-screen shot so you won't need to zoom to see my problem.

enter image description here

I need the labels in Java to be just as sharp as on the right. Is there a way to make JLabels not blurry?

Upvotes: 1

Views: 1899

Answers (1)

Gorbles
Gorbles

Reputation: 1168

I don't know, as you haven't provided any code, but if you have anti-aliasing enabled, that can cause the text to be displayed like it is:

    System.setProperty("awt.useSystemAAFontSettings","on"); 
    System.setProperty("swing.aatext", "true");

Try removing these (if they exist), or setting them to "off" and "false" respectively.

Upvotes: 1

Related Questions