是否有可能具有“可移动"/“可拖动"?JFrame 中的 JButton、JTextField 等组件?
基本上,我计划在 JFrame 上放置一些按钮、文本字段、标签等,并且我希望用户可以使用鼠标在该 JFrame 上移动不同的组件.
Basically I plan to place some buttons, textfields, labels, etc. on a JFrame and I would like to make it possible that a user can move the different components around on that JFrame with the mouse.
我已经看到了 MouseListeners、子类化 JComponent 代码、DropSource/DropTarget 实现等的各种方式,但我不确定哪种是推荐"方式(我不需要支持不同之间的拖放"框架/应用程序,这是大多数示例似乎所做的).
I have seen various ways with MouseListeners, subclassed JComponent code, DropSource/DropTarget implementations and so on, but I'm unsure which is the "recommended" way (I don't need to support "drag and drop" between different Frames/Applications which is what most examples seem to do).
推荐答案
Component Mover 可以为您做到这一点.
The Component Mover can do this for you.
相关文章