enable Anti Aliasing - Java 2D Graphics

Java examples for 2D Graphics:Graphics

Description

enable Anti Aliasing

Demo Code


//package com.java2s;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

public class Main {
    public static void enableAntiAliasing(Graphics g) {
        ((Graphics2D) g).setRenderingHint(
                RenderingHints.KEY_TEXT_ANTIALIASING,
                RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
        ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
    }/* www . j  a  va  2  s  . co  m*/
}

Related Tutorials