import javax.swing.*; import java.awt.*; import java.awt.geom.*; import java.awt.event.*; public class RenderingHintsTest extends JPanel { CubicCurve2D theCurve; BasicStroke bs; AffineTransform moveToTheRight; public static void main(String[] args) { JFrame f = new JFrame("RenderingHintsTest"); f.setContentPane(new RenderingHintsTest()); f.setSize(500, 500); f.setVisible(true); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public RenderingHintsTest() { theCurve = new CubicCurve2D.Float(10, 300, 20, 0, 100, 300, 230, 50); bs = new BasicStroke(7, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND); moveToTheRight = AffineTransform.getTranslateInstance(150, 0); } public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; //First draw the curve without antialiasing g2.setStroke(bs); g2.draw(theCurve); //Turn on antialiasing and draw the curve again, //beside the first curve. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setTransform(moveToTheRight); g2.draw(theCurve); } }