Java tutorial
import java.awt.Canvas; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Toolkit; import java.awt.geom.AffineTransform; import java.awt.geom.Line2D; import javax.swing.JFrame; public class Draw2DRotate extends JFrame { public static void main(String args[]) { Draw2DRotate app = new Draw2DRotate(); } public Draw2DRotate() { add("Center", new MyCanvas()); setSize(400, 400); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } } class MyCanvas extends Canvas { public void paint(Graphics graphics) { Graphics2D g = (Graphics2D) graphics; AffineTransform transform = AffineTransform.getRotateInstance(Math.PI / 16.0d); g.setTransform(transform); Line2D.Double shape = new Line2D.Double(0.0, 0.0, 300.0, 300.0); g.draw(shape); g.setFont(new Font("Helvetica", Font.BOLD, 24)); String text = ("Java2s"); g.drawString(text, 300, 50); Toolkit toolkit = Toolkit.getDefaultToolkit(); Image image = toolkit.getImage("image1.gif"); g.drawImage(image, 100, 150, this); } }