0
이클립스에서 아래의 코드를 테스트 해보려고하면 Java 애플릿이 나타나고 제게 사각형 만 보여줍니다. 그러나 (rect2) 사각형을 표시하지 않습니다.내 Java "GRect"클래스가 Eclipse에서 작동하지 않는 이유는 무엇입니까?
GRect Rect2 = new GRect (300, 75, 200, 100) ;
Rect2.setFilled (true) ;
Rect2.setColor (Color.RED) ;
add (Rect2) ;
또는 (GLabel) "hello world".
GLabel Label = new GLabel ("Hello, world, 100, 75") ;
Label.setFont(new Font("Courier New", Font.ITALIC, 12));
Label.setColor (Color.RED); add (Label) ;
전체 코드 :
import acm.graphics.*;
import acm.program.* ;
import java.awt.* ;
public class Test extends GraphicsProgram {
private static final long serialVersionUID = 3365078119967111934L;
public void run() {
GLabel Label = new GLabel ("Hello, world, 100, 75") ;
Label.setFont(new Font("Courier New", Font.ITALIC, 12));
Label.setColor (Color.RED);
add (Label) ;
GRect Rect1 = new GRect (10, 10, 50, 50) ;
add(Rect1) ;
GRect Rect2 = new GRect (300, 75, 200, 100) ;
Rect2.setFilled (true) ;
Rect2.setColor (Color.RED) ;
add (Rect2) ;
}
}
당신은 우리에게 코드를 좀 더 보여줄 필요가 - 작동하고 비트와 이러한 컨트롤 – Elemental
에있는 패널 여기에 전체 코드가 포함된다. 작동하는 유일한 것은 GRect1입니다. GRect2가 일식에 나타나지 않습니다. – Shazza