Graphics2D.setRenderingHint(RenderingHints.Key hintKey, Object hintValue) has the following syntax.
public abstract void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
In the following code shows how to use Graphics2D.setRenderingHint(RenderingHints.Key hintKey, Object hintValue) method.
import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; //from www . j av a2 s. co m import javax.swing.JFrame; import javax.swing.JPanel; public class Main extends JPanel { public void paint(Graphics g) { Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font font = new Font("Serif", Font.PLAIN, 96); g2.setFont(font); g2.drawString("jade", 40, 120); } public static void main(String[] args) { JFrame frame = new JFrame(); frame.add(new Main()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); } }