본문 바로가기
JAVA/예제

[JAVA] Graphics 웃는 얼굴

by JJH0100 2022. 10. 28.
728x90
반응형
package Ex01;

import java.awt.*;
import javax.swing.*;

class SnowPanel extends JPanel{
	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		g.setColor(Color.yellow);
		g.fillOval(20, 30, 200, 200);
		g.setColor(Color.BLACK);
		g.drawArc(60, 80, 50, 50, 180, -180);
		g.drawArc(150, 80, 50, 50, 180, -180);
		g.drawArc(80, 120, 100, 60, -180, 180);
	}
}

public class SnowMan extends JFrame{
	public SnowMan() {
		setSize(300, 300);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		add(new SnowPanel());
		setVisible(true);
	}
	public static void main(String[] args) {
		new SnowMan();
	}
}

728x90
반응형

'JAVA > 예제' 카테고리의 다른 글

[JAVA] 숫자 순서대로 클릭하기 게임  (0) 2022.10.28
[JAVA] Graphics 미니그림판  (0) 2022.10.28
[JAVA] 신호등  (0) 2022.10.28
[JAVA] addActionListener 카운터증가  (0) 2022.10.28
[JAVA] Label 클릭시 위치 랜덤 이동  (0) 2022.10.28

댓글