import java.util.*; import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class Clock02 { private JFrame frame = new JFrame("•`‰æ"); private JPanel pane = (JPanel)frame.getContentPane(); private Canvas canvas = new Canvas(){ @Override public void paint(Graphics g){ Graphics2D g2 = (Graphics2D)g; AffineTransform af = new AffineTransform(); for(int i = 0; i < 12; i++){ af.setToRotation(Math.PI / 6 * i, 200, 200); g2.setTransform(af); g2.fillOval(198, 0, 4, 20); } double sec = Math.PI / 3; af.setToRotation(sec, 200, 200); g2.setTransform(af); g2.setColor(Color.BLUE); g2.fillOval(198, 0, 4, 200); double min = Math.PI / 3 * 2; af.setToRotation(min, 200, 200); g2.setTransform(af); g2.setColor(Color.GREEN); g2.fillOval(195, 24, 10, 176); double hour = Math.PI; af.setToRotation(hour, 200, 200); g2.setTransform(af); g2.setColor(Color.RED); g2.fillOval(192, 100, 16, 100); } }; public Clock02(){ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); canvas.setBackground(Color.LIGHT_GRAY); canvas.setSize(400, 400); pane.add(canvas); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { new Clock02(); } }