我在一个类中写了paint(Graphics g)函数
public class A
{
public void paint(Graphics g)
{……}
}
,
而在另一个类中声明类A对象,并调用paint函数时,该向里传递什么参数?
public class B
{
A a=new A();
public void dd()
{
a.paint( ??? ); //怎样声明这个参数?
}
}
谢谢各位高手回答!
------解决方案--------------------
贴段代码说明一下吧
- Java code
import java.awt.Graphics;import javax.swing.JFrame;public class Tests { public void paint(Graphics g){ } } class B extends JFrame{ public B(){ } Tests a=new Tests(); public void dd(Graphics g){ a.paint(g); } //重写JFrame的paint方法在当中调用自子的绘图方法dd() @Override public void paint(Graphics g) { super.paint(g); this.dd(g);// } }