public void paint( Graphics g )
{
super.paint(g);
if (show_rough==true) //显示毛坯
{
g.setColor(color1);
g.fillRect( (600 - length_i) / 2, (500 - diameter_i) / 2,
(600 + length_i) / 2, (500 - diameter_i) / 2);
}
}谢谢
{
super.paint(g);
if (show_rough==true) //显示毛坯
{
g.setColor(color1);
g.fillRect( (600 - length_i) / 2, (500 - diameter_i) / 2,
(600 + length_i) / 2, (500 - diameter_i) / 2);
}
}谢谢
{
void prn()
{
System.out.println("I am in the A.prn()");
}
}public class B extends A
{
void prn()
{
super.prn(); //**
System.out.println("I am in the A.prn");
}
public static void main(String[] args)
{
B b=new B();
b.prn();
}
}
-----------------------------------------------------------------------------
在上面的代码中如果没有调用super.prn(),那么打印结果将只会显示"I am in the A.prn()",如果调用了将显示两条打印语句:
I am in the A.prn()
I am in the B.prn() 因此,在你上面的代码中,调用的super.paint(g),是为了让父类办你做一些事前的工作,如刷新屏幕、重绘图像等等,不明白的话在发短消息给我。
为什么不掉用会出现那个透明效果啊??