如果执行动作(例如按下按钮),我该如何平滑移动JButton。这里是我的例子,但它不propely工作:JButton在动作上的平滑移动
public void actionPerformed(ActionEvent event) {
for(int i = 0; i<50; i++){
ww.button.setLocation(ww.button.getLocation().x+1, ww.button.getLocation().y);//ww is a JFrame child
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
后所执行的操作,我得到的20 * 50毫秒,按钮位置在以前的LOC + 50像素设置延迟,无中间位置。
尝试使用布局。 – 2013-02-28 06:07:54
什么是ww?你也使用多态为你的按钮。你能展示更多的代码吗? – RyanDawkins 2013-02-28 06:07:56