0

以下のコードを Eclipse でテスト実行しようとすると、Java アプレットが表示され、正方形のみが表示されます。しかし、(rect2)長方形は表示されません

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) ; 
    }     
}
4

1 に答える 1