【发布时间】:2014-01-26 07:18:57
【问题描述】:
在摇摆环境中,我绘制按钮并设置动作以在我的框架上移动。
当我的按钮到达框架或按钮的角落并且框架的长度和宽度相等时;执行其他操作或类似的操作。
我的问题是我找不到任何组件来比较按钮和框架的位置或长度和宽度。
ActionListener al = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
x= x + 10 ;
y=y + 10 ;
jButtonMove.setLocation(x, y);
}
};
Timer t = new Timer(500 , al);
t.start();
【问题讨论】:
-
if (button.getWidth() + button.locationX()
-
@shved90 谢谢回复。