且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

向Jtree添加拖放支持

更新时间:2023-02-24 12:56:50

最简单的方法是
1.调用tree.setDragEnabled(true)
2.设置tree.transferHandler

The easiest way is to
1. Call tree.setDragEnabled(true)
2. set tree.transferHandler

在以下位置有一个教程: http://java.sun.com/docs/books/tutorial /uiswing/dnd/intro.html

There's a tutorial at: http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.html

您创建要在其中实现的TransferHandler的子类

You create a subclass of TransferHandler where you implement

canImport(JComponent comp, DataFlavor[] transferFlavors)

importData(JComponent comp, Transferable t)