0
是否有可能爲JButton添加任何監聽器,它應該等待上面的其他組件。 ClickComponent(我可以拖動的自己的對象)?聽上面的其他組件
+------------+
| BUTTON |
| +---------------+
+----| ClickComponent|
+---------------+
我想檢測到ClickComponent被拖到JButton以上。
ClickComponent被左上角拖動。
編輯
我嘗試用DropTarget
但並沒有發現我上面的組件/鼠標移動。
for(JButton button : buttonsList){
new DropTarget(button, new DropTargetAdapter() {
@Override
public void dragEnter(DropTargetDragEvent dtde) {
//log info if drag enter event catch
}
@Override
public void drop(DropTargetDropEvent dtde) {
// log info if drop event catch
}
});
}
我將它添加到所有按鈕,但它不起作用。不要抓住拖動事件 – czArek
你能告訴你如何編碼它嗎? – XtremeBaumer
http://pastebin.com/CrgSshzL – czArek