6

Is there any possibility to adjust font smoothing in Java swing application?

Here's some comparison:

enter image description here

The difference isn't huge, but if you look close enough, Adobe Story (and lot of other Flash applications) has stronger and nicer smoothing.

I write text editor in Java, and I would like to achieve such smoothing in my application on JTextPane and JLabels.

stmoebius
  • 662
  • 11
  • 30
Rafal
  • 61
  • 2
  • Have a look at this question: http://stackoverflow.com/questions/7593944/how-to-do-font-smoothing-for-awt-swing-application – Cyrille Ka Feb 19 '13 at 18:15
  • 1
    not true at all, agreed from this screenshots is difference big, for better help sooner post an [SSCCE](http://sscce.org/), short, runnable, compilable, just about a.m. described `My Java Application` – mKorbel Feb 19 '13 at 18:17
  • http://stackoverflow.com/questions/179955/how-do-you-enable-anti-aliasing-in-arbitrary-java-apps – arkon Apr 07 '13 at 14:36

2 Answers2

2

Depending on what Object you use to display your Text you need to make a custom one of it and Overwrite the method that is responsible for painting your Text

Here is an example of a custom JTextArea

public class CustomTextArea extends JTextArea {

    @Override
    public void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D) g.create();
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        super.paint(g);
    }

}

You may need to modify it some more but thats the basic concept

aldok
  • 17,295
  • 5
  • 53
  • 64
Dinh
  • 759
  • 5
  • 16
-4

You can use html tags on a Jlabel, like:

<html><body><br/><br/><body/><html/>

You can for example make a button, like so:

button = new JButton("<html><b><u>T</u>wo</b><br>lines</html>");

This looks like this: enter image description here

but here is more about HTML tags LINK

Hydroid
  • 119
  • 3
  • 16