Technote/JAVA 9주차 7번문제 by Pooh0216 2009. 5. 9. P9_7 P9_6 프로그램을 수정하여 한 번 그려진 원은 지워지지 않고 모두 화면에 나타나게 하시오. CircleComponent package p9_7; import javax.swing.JComponent; import java.awt.geom.Ellipse2D; import java.awt.*; public class CircleComponent extends JComponent{ int cnt = 0; final int MAX = 2000; CircleComponent(){ setPreferredSize(new Dimension(400, 400)); ellipse = new Ellipse2D.Double[MAX]; } public void setCenterPosition(int x, int y){ centerX = x; centerY = y; } public void drawCircle(int x, int y){ double radius = Math.sqrt( Math.pow((double)(centerX - x), 2.0) + Math.pow((double)(centerY - y), 2.0)); ellipse[cnt] = new Ellipse2D.Double(centerX - radius, centerY - radius, radius*2, radius*2); repaint(); cnt++; } public void paintComponent(Graphics g){ int i; for(i=0;i CircleComponentViewer package p9_7; import javax.swing.JComponent; import java.awt.geom.Ellipse2D; import java.awt.*; public class CircleComponent extends JComponent{ int cnt = 0; final int MAX = 2000; CircleComponent(){ setPreferredSize(new Dimension(400, 400)); ellipse = new Ellipse2D.Double[MAX]; } public void setCenterPosition(int x, int y){ centerX = x; centerY = y; } public void drawCircle(int x, int y){ double radius = Math.sqrt( Math.pow((double)(centerX - x), 2.0) + Math.pow((double)(centerY - y), 2.0)); ellipse[cnt] = new Ellipse2D.Double(centerX - radius, centerY - radius, radius*2, radius*2); repaint(); cnt++; } public void paintComponent(Graphics g){ int i; for(i=0;i 공유하기 게시글 관리 International Scholar Pooh 저작자표시 'Technote > JAVA' 카테고리의 다른 글 9주차 9번문제 (0) 2009.05.09 9주차 8번문제 (0) 2009.05.09 9주차 6번문제 (0) 2009.05.09 9주차 5번문제 (0) 2009.05.09 9주차 4번문제 (0) 2009.05.09 관련글 9주차 9번문제 9주차 8번문제 9주차 6번문제 9주차 5번문제