[英]oval leaves the trail
I am trying to make a simple ball animation, that starts from 1 corner and goes to another corner of the panel.我正在尝试制作一个简单的球 animation,它从一个角开始,然后到达面板的另一个角。 I have written a program for that.
我为此编写了一个程序。
When I run the program the oval
or ball leaves the trail.当我运行程序时,
oval
或球会离开轨迹。 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.在我的程序中,
timer
每 100 毫秒触发一次事件。
The following is the logic responsible for running the 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);
}
Screen shot of the output: output的屏幕截图:
Try尝试
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.