Java examples for 2D Graphics:Graphics
enable Antialiasing
//package com.java2s; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; public class Main { public static void enableAntialiasing(Graphics g) { if (g instanceof Graphics2D) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } else {// w w w . jav a2s . c om throw new RuntimeException("Need a graphics2D object"); } } }