import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class Stroke01 { private JFrame frame = new JFrame("̑"); private JPanel pane = (JPanel)frame.getContentPane(); private int w = 400, h = 400; private Canvas canvas = new Canvas(){ @Override public void update(Graphics g){ paint(g); } @Override public void paint(Graphics g){ Rectangle rec = g.getClipBounds(); w = rec.width; h = rec.height; Image img = createImage(w, h); Graphics2D g2 = (Graphics2D)img.getGraphics(); Ellipse2D ell1 = new Ellipse2D.Double(50, 100, 200, 200); Ellipse2D ell2 = new Ellipse2D.Double(150, 100, 200, 200); g2.setColor(Color.BLUE); g2.setStroke(new BasicStroke(5)); g2.draw(ell1); g2.setStroke(new BasicStroke(15)); g2.draw(ell2); g.drawImage(img, 0, 0, this); } }; public Stroke01(){ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); canvas.setBackground(Color.WHITE); canvas.setSize(w, h); pane.add(canvas); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { new Stroke01(); } }