Tag: 转移

将字符串添加到JList的确切位置,而不是底部

我有几个JList都可以成为DnD COPY动作的源和目的地。 它们工作正常,但有一点 – 元素添加在列表的底部,而不是像我想的那样添加到放置目标行。 由于Oracle BasicDnD示例包含此function(事实上,它是我能通过Google找到的唯一应用程序),我一直在查看其来源 ,看看我是否能够适应它。 我试图设置TransferHandler对象,这是我想我错过了,但没有出现新的行为。 那么,我可能会遗漏/做错什么? EDIT1:下面显示了我用于这些列表的类。 private class InteractiveJList extends JList implements DragGestureListener, DragSourceListener, DropTargetListener { private final DropTarget dropTarget; private final DragSource dragSource; private final boolean removeElementsOnFail; private int[] selectedOnes; @SuppressWarnings(“unchecked”) private InteractiveJList(final ListModel model, final boolean _removElementsOnFail) { super(model); this.dragSource = new DragSource(); this.dragSource .createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, this); this.dropTarget […]