As posts on many Java discussion forums (including this one) note, fonts by default look really ugly in Swing. So far, the best advice I've read for improving Swing's font rendering is to subclass a JComponent's pain() method, and to specify that instances of that component use anti-aliasing. However, I found that to be a tedious process. I have an app that uses every possible kind of Swing component, and I'd have to have to subclass every Swing UI component just for this purpose.
My first question: Is there a better way? Is there some hidden system property that would cause Swing to antialias fonts by default?
In addition, I'm wondering if antialiasing is the only way to improve Swing's font rendering. I'm primarily talking about Windows here, because in Windows there is a clear difference in font quality when you run a Swing app and a native Windows app side-by-side. I'm curious to hear what others are doing to make Swing apps look prettier on Windows.
Unfortunately, even with the native look and feel set, Swing font rendering is subpar compared with native apps. So while Swing gets its font information from the platform, it does not render those fonts on the screen as a native app would.
Once I tried this with my swing app. I was using different swing components like JComboBox and others. I tried to do this. E.g. For JCombobox, I used to add JLabel component for each option in the combobox.
Font f = new Font("Arial", 5, 8); JLabel label = new JLabel(); label.setFont(f); label.setText("Option Name");