import java.awt.*; /** An example of coordinate translations and * rotations with Java2D in Java 1.2. * 1998 Marty Hall, http://www.apl.jhu.edu/~hall/java/ */ public class DrawExample5 extends DrawExample4 { public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D)g; g2d.clearRect(0, 0, getSize().width, getSize().height); drawFilledCircle(g2d); drawHollowCircle(g2d); g2d.setPaint(Color.black); // Move the origin to the center of the circle. g2d.translate(185.0, 185.0); for (int i=0; i<16; i++) { // Rotate the coordinate system (around current // origin, which is at the center of the circle). g2d.rotate(Math.PI/8.0); g2d.drawString("Java", 0, 0); } } public static void main(String[] args) { WindowUtil.openInJFrame(new DrawExample5(), 380, 400); } }