import java.awt.*; 
import java.awt.event.*; 
public class TankClient extends Frame{ 
public void paint(Graphics g) { 
Color c=g.getColor(); 
g.setColor(Color.RED); 
g.fillOval(100,100, 20, 20); 
g.setColor©; } public void lauthFrame() { 
this.setLocation(100,100); 
this.setSize(800,600); 
this.setVisible(true); 
this.setTitle("112233"); 
this.setResizable(false); 
this.addWindowListener(new WindowAdapter() { 
public void windowClosing(WindowEvent e) { 
System.exit(0); 

}); } 
public static void main(String[] args) { TankClient tc = new TankClient(); 
tc.lauthFrame(); 
} } 
这个程序 中的paint方法 在那里被调用的????    多谢了  我刚开始学java 可能这个问题很弱智   但也请告诉我   多谢了  
 
 

解决方案 »

  1.   

    没有看到你掉用paint()的代码.
      

  2.   

    paint()方法自动被调用了。就在launchFrame()的时候。
      

  3.   

    tc.lauthFrame();之后
    你可以用断点调试一下,或加几个system.out语句就可以很清楚的看出来.
      

  4.   

    那么 Frame()  是被谁调用的  自动调用 也应该 有一个条件吧
      

  5.   

    TankClient 是从FRAME继承的,tc在调用lauchFrame()的时候调用了paint()方法。马士兵的教程中有这个TankClient的内容,但是不建议先看,应该先看看他的GUI教程。
      

  6.   

    面向对象中讲到的封装和继承,paint()方法从Frame类里继承而来,覆盖了Frame类的paint()方法,awt线程会不时的去调用它的repaint()方法,然后通过调用update()方法清空窗口的内容,然后进而调用paint()方法,面向对象不用知道底层的实现,即不用去管细节问题,只要完成了你的功能即可,呵呵!
      

  7.   

    paint(Graphics g) 是在java.awt.Component中的方法 Frame是从这个类继承下来的