If you use a system property it will use if it supports it
and it will ignore it when it doesn't support it.
For anti-aliasing it would be:
-Dswing.aatext=true
Programmaticaly you could do (before any GUI is
initialized):
System.setProperty("swing.aatext",
"true");
Kind regards,
Manfred Riem
Manfred Riem
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jay Askren
Sent: Friday, August 25, 2006 10:59 AM
To: LDS Open Source Software
Subject: Re: [Ldsoss] AntiAlias Java
I tried your code on version of 1.5_04 of java and it didn't work.
SwingUtilities2 is not mentioned in the javadocs for Java 1.5, so I looked at
the code for SwingUtilities2 source code, and it appears that SwingUtilities2 is
not stable, and the the comments said to not rely on the class.
I did find the following links:
So it looks like at least for now using the RenderingHints might be a bit
more robust though I haven't tried it. It should work with Java 1.4.
On 8/24/06, Tom Welch
<[EMAIL PROTECTED]>
wrote:
Many java applications if using swing tend to have really ugly UI's. The fonts look terrible. I wrote some code that can make them look a whole lot better. This code requires jre 1.5. Simply put this method into some type of utilities class and then call it whenever you want to make a component anti-aliased. It will find all child components and anti-alias them as well. You typically just call this method from each form or dialog and all components on the form will get fixed. I've tested this under both Windows and Linux and it works well.
Disclaimer: I'm not a long time java developer so if you see obvious problems or could offer suggestions, please do so.
public static void AntiAliasComponent(JComponent j) {
j.putClientProperty (com.sun.java.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY,Boolean.TRUE);
int y = j.getComponentCount();
for (int x=0;x<y;x++) {
java.awt.Component comp = j.getComponent(x);
if (comp instanceof JComponent) {
AntiAliasComponent((JComponent)comp);
}
// Additional checks for certain types of controls. These require special handling
if (comp instanceof JList) {
JList jl = (JList)comp;
DefaultListCellRenderer d=(DefaultListCellRenderer)jl.getCellRenderer();
d.putClientProperty(com.sun.java.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY ,Boolean.TRUE);
}
else if (comp instanceof JComboBox) {
JComboBox cb = (JComboBox)comp;
BasicComboBoxRenderer d=(BasicComboBoxRenderer)cb.getRenderer();
d.putClientProperty(com.sun.java.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY, Boolean.TRUE);
}
else if (comp instanceof JTable) {
JTable tab = (JTable)comp;
DefaultTableCellRenderer d;
d = (DefaultTableCellRenderer)tab.getDefaultRenderer(JLabel.class);
d.putClientProperty(com.sun.java.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY , Boolean.TRUE);
// Do the headers
d = (DefaultTableCellRenderer)tab.getTableHeader().getDefaultRenderer();
d.putClientProperty(com.sun.java.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY , Boolean.TRUE);
}
}
}
Here is a sibling function to anti-alias the menus of a form. Simply call this for your main menu bar and it will fix all sub-menus.
public static void AntiAliasMenu(JMenuBar j)
{
int a = j.getMenuCount();
for (int b=0;b<a;b++) {
int x=j.getMenu(b).getItemCount();
j.getMenu(b).putClientProperty(com.sun.java.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY ,Boolean.TRUE);
for (int y=0;y<x;y++) {
JMenuItem jmi = j.getMenu(b).getItem(y);
if (jmi!=null)
iii.putClientProperty(com.sun.java.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY , Boolean.TRUE);
}
}
}
Enjoy.
Tom
------------------------------------------------------------------------------NOTICE: This email message is for the sole use of the------------------------------------------------------------------------------
intended recipient(s) and may contain confidential and
privileged information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the
intended recipient, please contact the sender by reply email
and destroy all copies of the original message.
_______________________________________________
Ldsoss mailing list
Ldsoss@lists.ldsoss.org
http://lists.ldsoss.org/mailman/listinfo/ldsoss
_______________________________________________ Ldsoss mailing list Ldsoss@lists.ldsoss.org http://lists.ldsoss.org/mailman/listinfo/ldsoss