在该DragGestureHandler::dragGestureRecognized方法中,变量被调用parent,因此隐藏了实例的parent变量。解决起来很容易。当我使用给定的代码时,我得到一个java.awt.dnd.InvalidDnDOperationException: Cannot find top-level for the drag source component。如果我将第一行(直到parent.repaint();方法的最底部,则不再抛出异常。区别在于new PanelTransferable(getPanel());从面板中 获取了。为什么会这样呢?)