use of java.awt.dnd.DropTarget in project jdk8u_jdk by JetBrains.
the class SunDropTargetContextPeer method processExitMessage.
/**
*
*/
protected void processExitMessage(SunDropTargetEvent event) {
Component c = (Component) event.getSource();
DropTarget dt = c.getDropTarget();
DropTargetContext dtc = null;
if (dt == null) {
currentDT = null;
currentT = null;
if (currentDTC != null) {
currentDTC.removeNotify();
}
currentDTC = null;
return;
}
if (dt != currentDT) {
if (currentDTC != null) {
currentDTC.removeNotify();
}
currentDT = dt;
currentDTC = dt.getDropTargetContext();
currentDTC.addNotify(this);
}
dtc = currentDTC;
if (dt.isActive())
try {
((DropTargetListener) dt).dragExit(new DropTargetEvent(dtc));
} catch (Exception e) {
e.printStackTrace();
} finally {
currentA = DnDConstants.ACTION_NONE;
currentSA = DnDConstants.ACTION_NONE;
currentDA = DnDConstants.ACTION_NONE;
currentDT = null;
currentT = null;
currentDTC.removeNotify();
currentDTC = null;
local = null;
dragRejected = false;
}
}
use of java.awt.dnd.DropTarget in project pcgen by PCGen.
the class NotesView method initDnDComponents.
private void initDnDComponents() {
filesBarDT = new DropTarget(filesBar, new DropBarListener());
treeDT = new DropTarget(notesTree, new DropTreeListener());
}
use of java.awt.dnd.DropTarget in project knime-core by knime.
the class SelectionPanel method createIncludePanel.
private void createIncludePanel() {
m_includePanel = new JPanel(new GridBagLayout());
new DropTarget(m_includePanel, DnDConstants.ACTION_MOVE, this, true, null);
m_scrollPane = new JScrollPane(m_includePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
m_scrollPane.setPreferredSize(new Dimension(300, 200));
m_scrollPane.getVerticalScrollBar().setUnitIncrement(20);
MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() {
int lasty = 0;
@Override
public void mouseDragged(final MouseEvent e) {
if (Math.abs(lasty - e.getY()) < 10) {
int i = m_scrollPane.getVerticalScrollBar().getValue();
if (e.getY() > lasty) {
m_scrollPane.getVerticalScrollBar().setValue(i + 2);
} else if (e.getY() < lasty) {
m_scrollPane.getVerticalScrollBar().setValue(i - 2);
}
}
if (e.getY() < 10) {
lasty = 10;
} else if (e.getY() > m_includePanel.getVisibleRect().getMaxY()) {
lasty = (int) m_includePanel.getVisibleRect().getMaxY() - 10;
} else if (Math.abs(lasty - e.getY()) > 10) {
lasty = e.getY();
}
}
};
m_includePanel.addMouseMotionListener(doScrollRectToVisible);
m_includePanel.setAutoscrolls(true);
}
use of java.awt.dnd.DropTarget in project com.revolsys.open by revolsys.
the class FileDropTargetListener method hierarchyChanged.
@Override
public void hierarchyChanged(final HierarchyEvent event) {
final Component component = event.getComponent();
final java.awt.Component parent = component.getParent();
if (parent == null) {
component.setDropTarget(null);
} else {
new DropTarget(component, this);
}
}
use of java.awt.dnd.DropTarget in project com.revolsys.open by revolsys.
the class FileDropTargetListener method addDropTarget.
public void addDropTarget(final Component component) {
if (component.getParent() != null) {
new DropTarget(component, this);
}
component.addHierarchyListener(this);
if (component.getParent() != null) {
new DropTarget(component, this);
}
if (component instanceof Container) {
final Container container = (Container) component;
final Component[] components = container.getComponents();
for (final Component child : components) {
addDropTarget(child);
}
}
}
Aggregations