在拖放 JTable 中单击
抱歉,如果之前有人问过这个问题,我到处谷歌搜索但没有运气。 这是我的问题:我想在 JTable 中拖放行。如果不先选择行,我就无法让它工作,这很烦人,我想得到 Windows 资源管理器的类似行为:如果我单击一个项目并在按住左键的同时开始移动鼠标,它会拖动在我的行中,如果我在其他地方单击并在按住左键的同时开始移动鼠标,则会对行进行多重选择。 非常感谢任何帮助
Sorry if this was asked before, I googled everywhere with no luck.
Here's my problem: I'd like to drag and drop rows within a JTable. I cannot get it to work without first selecting the row, which is annoying, I'd like to get a similar behavior the Windows explorer has : if I single click on an item and start moving the mouse while holding the left button, it drags my row, if I single click elsewhere and start moving the mouse while holding the left button, it does a multiple selection of the rows.
Any help is greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要添加一个鼠标侦听器来侦听 mousePressed 事件,然后使选择的行成为鼠标光标当前所在的行。
You probably need to add a mouse listener that listens for mousePressed events, and then cause the selection of the row to be the row the mouse cursor is currently over.