import java.awt.*;
import java.awt.event.*;public class TankClient extends Frame
{  
    
public void print(Graphics g) {
  Color c = g.getColor();
  g.setColor(Color.red);
  g.fillOval(50, 50, 30, 30);   //使用当前颜色填充外接指定矩形框的椭圆。
  g.setColor(c);

}
public void lauchFrame()
        {  
                 
         this.setLocation(80, 60);
         this.setSize(800, 500);
         this.setTitle("画圆");            
         this.addWindowListener(new WindowAdapter()
         {
public void windowClosing(WindowEvent e)
{
System.exit(0);
}      
         });
         this.setResizable(false);
         this.setBackground(Color.GREEN);
         setVisible(true);
        }
public static void main(String[] args) 
{
        TankClient tc = new TankClient();
        tc.lauchFrame();
        
}}
在生成窗口后print函数是否能自动调用?若能的话怎么生不成红色的圆呢

解决方案 »

  1.   

    不能自动调用,你做得是Frame不是applet
      

  2.   

    一楼的意思是在Frame中不能自动调用,那应该怎么该呢,原谅我吧,的确...
      

  3.   

    什么重画不重画的,明明就是  paint  打错了。
    搞笑!
    程序当然不会报错啦!
      

  4.   

    看来楼上也是没有明白swt的原理呀 .............支持下楼主
      

  5.   

    public void print(Graphics g) { 
      Color c = g.getColor(); 
      g.setColor(Color.red); 
      g.fillOval(50, 50, 30, 30);   //使用当前颜色填充外接指定矩形框的椭圆。 
      g.setColor(c); } 
    应该是定义错误吧...
    既然楼主解决了,twlhmq198821你也不用这么火气大嘛 
    呵呵,大家和谐,共同进步