The Artima Developer Community
Sponsored Link

Java Answers Forum
Improving Swing fonts?

3 replies on 1 page. Most recent reply: Jan 25, 2004 5:16 PM by Sachin Joshi

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Improving Swing fonts? Posted: Jan 22, 2004 9:17 PM
Reply to this message Reply
Advertisement
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.


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Improving Swing fonts? Posted: Jan 22, 2004 10:42 PM
Reply to this message Reply
How about setting the windows look and feel to the application?

The swing application gets the font like that of other windows/vb application?

Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Re: Improving Swing fonts? Posted: Jan 23, 2004 9:24 AM
Reply to this message Reply
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.

Sachin Joshi

Posts: 12
Nickname: aspire
Registered: Jan, 2004

Re: Improving Swing fonts? Posted: Jan 25, 2004 5:16 PM
Reply to this message Reply
Hi,

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");

JComboboxOBJECT.add(label);

Hope, it gives some hint.

Sachin

Flat View: This topic has 3 replies on 1 page
Topic: copy subject Previous Topic   Next Topic Topic: JAVA DEVELOPERS

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use