展开全部
移动圆,改变它的圆心e69da5e887aa3231313335323631343130323136353331333337613231即可,可以通过给圆心设置一个运动轨迹函数实现,实例代码为;public class joinDemo1 extends JFrame
{
//继承
private int x=100, y=100, r=100;
//初始值
public joinDemo1()
{
super("小图形");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(800, 600);
this.setVisible(true);
Thread thread=new Thread(new Graphicss());
thread.start();
}
public void paint(Graphics g)
{
super.paint(g);
g.fillOval(x, y, r, r);
}
public static void main(String[] args)
{
new joinDemo1();
}
class Graphicss implements Runnable{
@Override
public void run() {
// TODO Auto-generated method stub
for (int j = 0; j <= 240; j++) {
revalidate();
// System.out.println(j);
try {
Thread.sleep(1000);// 当前线程休眠0.01秒
} catch (InterruptedException e) {
e.printStackTrace();
}
y=y+j;
repaint();
}
}
}
}