javaお絵描き

import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Rei22 extends Frame {
	public Rei22(){
		setSize(300,200);
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}
	public void paint(Graphics g) {
		g.drawRect(40,40,50,50);
		g.drawRoundRect(100, 40, 50, 50, 10, 10);
		g.drawOval(160, 40, 50, 50);
		g.drawArc(220, 40, 50, 50, 45, 270);
		g.fillRect(40, 100, 50, 50);
		g.fillRoundRect(100, 100, 50, 50, 10, 10);
		g.fillOval(160, 100, 50, 50);
		g.fillArc(220, 100, 50, 50, 45, 270);
		g.drawLine(40, 180, 260, 180);
	}
	public static void main(String[] args) {
		Frame w = new Rei22();
		//w.show();
		w.setVisible(true);
	}
}

パックマンみたいなのがいる

実行結果:
pac

コメントを残す