为了账号安全,请及时绑定邮箱和手机立即绑定

请教paintComponents()和paint()方法的区别

请教paintComponents()和paint()方法的区别

月亮岛Superman 2017-06-03 00:31:05
public class TankClient extends Frame { public void paintComponents(Graphics g) { Color c = g.getColor(); g.setColor(Color.RED); g.fillOval(50, 50, 30, 30); g.setColor(c); } public void lauchFrame() { this.setBounds(80, 80, 800, 600); this.setVisible(true); this.setResizable(false); this.setTitle("TankWar"); this.setBackground(Color.GREEN); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); }}); } public static void main(String[] args) { new TankClient().lauchFrame(); }}请教下paintComponents()方法和paint()方法的区别在这个程序中使用paintComponents 划不出来圆   但是用paint()方法就可以这是为什么?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 1653 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号