为什么print(Graphics g) 没有被调用,如图


import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Tank extends JFrame{
    
    private MyPlane mp=null;
    public static void main(String[] args) {
        new Tank();        
    }

    public Tank() {
        mp = new MyPlane();
        this.add(mp);
        this.setSize(400, 300);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);        
        }
    }
class MyPlane extends JPanel{
@Override
public void print(Graphics g) {    
    super.print(g);
    System.out.print("被调用");
    g.drawOval(10, 10, 100, 100);
}
}

img

我知道了,我把paint写成print了!!

因为你压根没去调过他
至少你贴出的代码中没看到

你只写了个继承类,又没有代码去实例化这个类,它为什么会被调用呢