是否有可能具有“可移动"/“可拖动"?JFrame 中的 JButton、JTextField 等组件? [英] Is it possible to have "movable"/"draggable" components like JButtons, JTextFields in a JFrame?

查看:27
本文介绍了是否有可能具有“可移动"/“可拖动"?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.

这篇关于是否有可能具有“可移动"/“可拖动"?JFrame 中的 JButton、JTextField 等组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆