新手:下面程序中paint()方法如何被调用的,有高手能帮助解释一下吗?
先谢谢各位大侠了!
前两个是超类定义,分别为DrawPanel, DrawFrame,具体如下:
import java.awt.*;
import javax.swing.*;
public class DrawPanel extends JPanel{
private int width=300;
private int height=300;
protected DrawPanel(){
setPreferredSize(new Dimension(width,height));
}
protected DrawPanel(final int w,final int h){
width=w;
height=h;
setPreferredSize(new Dimension(width,height));
}
public int getWidth(){
return width;
}
public int getHeight(){
return height;