我对Trident Animation Library非常陌生,但我设法将它用于我的动画,它工作得真的很好。
我的要求基本上是从容器的一个角落到容器的中间为JComponent设置动画。
下面是我的伪代码
this.setLayout(null);
JButton button = new JButton();
button.setLocation(new Point (0,0));
Point center = new Point(getWidth()/2, getHeight()/2);
Timeline timeline = new Timeline(notification.getComponent());
timeline.addPropertyToInterpolate("location", button .getLocation(), center );
timeline.setDuration(1000);
timeline.play();现在,当我的容器调整大小时,容器的中心会发生变化。对于e.x:如果容器的初始中心是(100,100),并且在容器调整大小后,新的中心是(200,200)。
有没有什么方法可以在插值时反映新的中心,使组件移动到(200,200)而不是(100,100)?请帮帮忙。
发布于 2012-05-11 05:41:23
这是我脑海中浮现的第一件事:
在开始时存储当前窗口/面板大小。在每个时间线‘滴答’检查当前的窗口/面板大小是否与您开始时的不同(例如:面板已调整大小)。如果已调整大小,则停止当前时间轴,并基于新的面板中心创建具有新路径的新时间轴。
https://stackoverflow.com/questions/10536229
复制相似问题