Easiest way to make a list-like widget with drag a

2019-05-07 19:38发布

问题:

The simplest example I can think of are playlists, where you can drag a song to a different position in the list.

I've done quite a few things with Swing but I've never seen an example with something like this.

回答1:

Here's an example that might be close to what you want http://www.java2s.com/Code/Java/Swing-JFC/DragandDropJListandList.htm

There is a demo in the Oracle page linked in the comment to the first question: http://download.oracle.com/javase/tutorial/uiswing/dnd/basicdemo.html

Direct link: http://download.oracle.com/javase/tutorial/uiswing/examples/dnd/BasicDnDProject/src/dnd/BasicDnD.java