package hello2d; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Ellipse2D; import javax.swing.JFrame; import javax.swing.JPanel; public class Hello2D { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new Hello2DPanel()); frame.setSize(640, 480); frame.setVisible(true); } } class Hello2DPanel extends JPanel { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setColor(Color.BLUE); Ellipse2D e = new Ellipse2D.Double(-50, 50, 50, 50); AffineTransform tr = new AffineTransform(); Shape shape = tr.createTransformedShape(e); g2.translate(100, 100); g2.scale(2, 2); g2.draw(shape); } }