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()方法就可以這是為什么?
請教paintComponents()和paint()方法的區別
月亮島Superman
2017-06-03 00:31:05