안녕하세요, 페인트 방법을 호출하는 방법을 알고 싶습니다 ...페인트 방법을 호출하는 방법을 모르겠다
저는 초보 프로그래머이며 페인트와 같은 것을 실험하고 있습니다.
내가 만들고자하는 프로그램은 3 단이있는 게임이며 게임의 목적은 다른 크기의 디스크를 왼쪽/오른쪽 단계에서 오른쪽/왼쪽 단계로 옮기는 것입니다. 당신은 그것을 호출 할 필요는 없습니다
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int amount = 0;
// get the amount of rectangles to draw to represent disks
while (amount <= 1 && amount >= 5) {
System.out.print("Please enter amount of discs to use(less than 7 more than one).");
amount = scan.nextInt();
}
}
public void paint(Graphics g) {
// draw a certain amount of rectangles in ascending order
if (amount <= 1 && amount >= 5) {
for (int i = 0; i < amount; i++) {
g.fillRect(220 - (20 * i), 200 + (10 * i), 100 - (20 * i), 20);
}
}
}
동급 클래스는 무엇입니까? 'JFrame'? – pajton