简单绘制小球模拟平抛 非重力加速度9.8 可更改参数
import javax.swing.*;
import java.awt.*;
public class shiyan6 extends JFrame
{
shiyan6()
{
setSize(1500,1000);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void paint(Graphics g)
{
for (int i = 0; i<=30;i++)
{
g.clearRect(0,0,1500,1000);
g.fillOval(100 + 20*i, (int) (1*i*i+100),20,20);
try {
Thread.currentThread().sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public static void main(String args[])
{
new shiyan6();
}
}