叶椭圆形步道 [英] oval leaves the trail

查看:176
本文介绍了叶椭圆形步道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个简单的球的动画,从1边角开始,转到面板的另一个角落。我写了一个程序的。

I am trying to make a simple ball animation, that starts from 1 corner and goes to another corner of the panel. I have written a program for that.

当我运行程序的椭圆留下的踪迹。我的意思说的是,它的叶子是'颜色踪迹当程序运行时。在我的节目定时器触发一个事件每100毫秒。

When I run the program the oval or ball leaves the trail. What I mean to say is that it leaves it's 'color trail' when the program runs. In my program timer fires an event every 100 milliseconds.

以下是负责运行code逻辑:

void function() {
  // in this there is a action listener timed accordingly to fire event of 
  // doing x++ every 100th miliseconds
}

public void paintComponent(final Graphics g) {
 g.setColor(Color.black);
 g.drawOval(x,y,width,height);
 g.fillOval(x,y,width,height);
}

截屏输出:

推荐答案

尝试

public void paintComponent(final Graphics g) {
 super.paintComponent(g);

 g.setColor(Color.black);
 g.drawOval(x,y,width,height);
 g.fillOval(x,y,width,height);
}

这篇关于叶椭圆形步道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆