dcsimg

How do I use antialiasing in Java?

John Zukowski

In your paint() method, add the following hint at the top of the method:


((Graphics2D)g).setRenderingHint
  (RenderingHints.KEY_ANTIALIASING,
   RenderingHints.VALUE_ANTIALIAS_ON); 

[FAQ Manager Note] This will only work in Java2. In JDK 1.x, you cannot perform antialias automatically (you would have to write your own antialiasing routines)