javax.swing.TransferHandler#DropLocation ( )源码实例Demo

下面列出了javax.swing.TransferHandler#DropLocation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@SuppressWarnings("unchecked")
@Override
public boolean importData(TransferSupport info) {
	TransferHandler.DropLocation dropLocation = info.getDropLocation();
	if (!canImport(info) || !(dropLocation instanceof JList.DropLocation)) {
		return false;
	}

	JList.DropLocation dl = (JList.DropLocation) dropLocation;
	JList target = (JList) info.getComponent();
	DefaultListModel listModel = (DefaultListModel) target.getModel();
	int max = listModel.getSize();
	int index = dl.getIndex();
	index = index < 0 ? max : index;
	// make sure to append at the end if index > size
	index = Math.min(index, max);

	addIndex = index;

	try {
		Object[] values = (Object[]) info.getTransferable().getTransferData(localObjectFlavor);
		for (Object value : values) {
			int idx = index++;
			listModel.add(idx, value);
			target.addSelectionInterval(idx, idx);
		}
		addCount = values.length;
		return true;
	} catch (UnsupportedFlavorException | IOException e) {
		// should never happen, log anyway to be safe
		LogService.getRoot().log(Level.WARNING, "com.rapidminer.gui.tools.dnd.ExtendedJListTransferHandler.unexpected_error", e);
	}

	return false;
}
 
源代码2 项目: jeveassets   文件: ShowToolSettingsPanel.java
@SuppressWarnings("unchecked")
@Override
public boolean importData(TransferSupport info) {
	TransferHandler.DropLocation tdl = info.getDropLocation();
	if (!canImport(info) || !(tdl instanceof JList.DropLocation)) {
		return false;
	}

	JList.DropLocation dl = (JList.DropLocation) tdl;
	JList<?> target = (JList) info.getComponent();
	DefaultListModel<Object> listModel = (DefaultListModel) target.getModel();
	int max = listModel.getSize();
	int index = dl.getIndex();
	index = index < 0 ? max : index; // If it is out of range, it is appended to the end
	index = Math.min(index, max);

	addIndex = index;

	try {
		Object[] values = (Object[]) info.getTransferable().getTransferData(localObjectFlavor);
		for (Object value : values) {
			int idx = index++;
			listModel.add(idx, value);
			target.addSelectionInterval(idx, idx);
		}
		addCount = values.length;
		return true;
	} catch (UnsupportedFlavorException | IOException ex) {
		LOG.error(ex.getMessage(), ex);
		return false;
	}
}
 
源代码3 项目: dragonwell8_jdk   文件: SwingAccessor.java
/**
 * Calculates a custom drop location for the text component,
 * representing where a drop at the given point should insert data.
 */
TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p);
 
源代码4 项目: dragonwell8_jdk   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);
 
源代码5 项目: TencentKona-8   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);
 
源代码6 项目: jdk8u60   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);
 
源代码7 项目: jdk8u-jdk   文件: SwingAccessor.java
/**
 * Calculates a custom drop location for the text component,
 * representing where a drop at the given point should insert data.
 */
TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p);
 
源代码8 项目: openjdk-jdk8u   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);
 
源代码9 项目: openjdk-jdk8u-backup   文件: SwingAccessor.java
/**
 * Calculates a custom drop location for the text component,
 * representing where a drop at the given point should insert data.
 */
TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p);
 
源代码10 项目: jdk8u-dev-jdk   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);
 
源代码11 项目: jdk8u-jdk   文件: SwingAccessor.java
/**
 * Calculates a custom drop location for the text component,
 * representing where a drop at the given point should insert data.
 */
TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p);
 
源代码12 项目: jdk8u-jdk   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);
 
源代码13 项目: hottub   文件: SwingAccessor.java
/**
 * Calculates a custom drop location for the text component,
 * representing where a drop at the given point should insert data.
 */
TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p);
 
源代码14 项目: hottub   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);
 
源代码15 项目: openjdk-8-source   文件: SwingAccessor.java
/**
 * Calculates a custom drop location for the text component,
 * representing where a drop at the given point should insert data.
 */
TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p);
 
源代码16 项目: openjdk-8-source   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);
 
源代码17 项目: jdk8u-dev-jdk   文件: SwingAccessor.java
/**
 * Calculates a custom drop location for the text component,
 * representing where a drop at the given point should insert data.
 */
TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p);
 
源代码18 项目: openjdk-8   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);
 
源代码19 项目: jdk8u-jdk   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);
 
源代码20 项目: jdk8u_jdk   文件: SwingAccessor.java
/**
 * Called to set or clear the drop location during a DnD operation.
 */
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
                       Object state, boolean forDrop);