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()方法就可以这是为什么?
添加回答
举报
0/150
提交
取消