主题:各位老师,帮初学者解一个惑,感谢!
小弟初入java大门,遇到一道画图的练习题,按照要求写了,可是运行结果竟然是空的!
eclipse下,新建project名为Exercise,新建名为Exercise的class,代码如下:
import java.awt.*;
import java.applet.Applet;
public class Exercise extends Applet{
public void Paint(Graphics graphics) {
Point aPoint = new Point(0,0);
Door Door1 = new Door(aPoint);
Door1.draw(graphics);
}
}
再新建名为Door的class,代码如下:
import java.awt.*;
public class Door {
private Point p1;
public Door (Point aPoint)
/*
Construct the Door so that its upper left corner is at the given Point.
*/
{
this.p1 = new Point(aPoint);
}
public void draw(Graphics graphics)
/*
Draws only one door on the given Graphics.
*/
{
graphics.drawRect(this.p1.x, this.p1.y, 20, 30);
graphics.fillOval(this.p1.x,this.p1.y,5,5);
}
}
题目运行要求是画出一个门,一个门把手~
可是我的这些代码运行后窗口里是空的!实在不知道错在了哪里!我刚学了几天,还在摸索和试图了解的阶段!请各位老师给予支持和指导,万分感谢![em59]
eclipse下,新建project名为Exercise,新建名为Exercise的class,代码如下:
import java.awt.*;
import java.applet.Applet;
public class Exercise extends Applet{
public void Paint(Graphics graphics) {
Point aPoint = new Point(0,0);
Door Door1 = new Door(aPoint);
Door1.draw(graphics);
}
}
再新建名为Door的class,代码如下:
import java.awt.*;
public class Door {
private Point p1;
public Door (Point aPoint)
/*
Construct the Door so that its upper left corner is at the given Point.
*/
{
this.p1 = new Point(aPoint);
}
public void draw(Graphics graphics)
/*
Draws only one door on the given Graphics.
*/
{
graphics.drawRect(this.p1.x, this.p1.y, 20, 30);
graphics.fillOval(this.p1.x,this.p1.y,5,5);
}
}
题目运行要求是画出一个门,一个门把手~
可是我的这些代码运行后窗口里是空的!实在不知道错在了哪里!我刚学了几天,还在摸索和试图了解的阶段!请各位老师给予支持和指导,万分感谢![em59]