> I found this line very interesting:
> $ java -jar lib/application.jar -Dswing.aatext=true
>
> But exactly where do I put it? :D
You put it right there on the command line, when you invoke the JVM and run your application. It's defining a system property that the Swing libraries check to see that you want to do global antialiasing.
> So everyone that wants to run my program has to use
> that line ?
You can override the paintComponent() method to use anti-aliasing.
JLabel myLabel = new JLabel()
{
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g2);
}
};
That should do the trick.
> Yeah I've tried this one and it works. But It's a lot
> of extra code to type that everytime I make a JLabel.
> Is there a way to make a method of it?
Then you can make your own class that overrides the method. That way you would only need to type.
AntiAliasedLabel myLabel = new AntiAliasedLabel("...");
Yeah, making a new class is probably the best.
I was helped from a very kind person called Woflborg (#java QNet).
This code works perfect...
<code>
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.*;
public class AAJLabel extends JLabel
{
public AAJLabel(String s)
{
super(s);
}
public AAJLabel()
{
super();
}
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
super.paint(g);
}
}
</code>
Message was edited by:
N1klas