use of java.awt.dnd.DropTarget in project jdk8u_jdk by JetBrains.
the class MissingDragExitEventTest method initAndShowUI.
private static void initAndShowUI() {
frame = new JFrame("Test frame");
frame.setSize(SIZE, SIZE);
frame.setLocationRelativeTo(null);
final JTextArea jta = new JTextArea();
jta.setBackground(Color.RED);
frame.add(jta);
jta.setText("1234567890");
jta.setFont(jta.getFont().deriveFont(150f));
jta.setDragEnabled(true);
jta.selectAll();
jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY, new TestdropTargetListener()));
jta.addMouseListener(new TestMouseAdapter());
frame.setVisible(true);
}
use of java.awt.dnd.DropTarget in project jdk8u_jdk by JetBrains.
the class MissingEventsOnModalDialogTest method main.
public static void main(String[] args) throws Exception {
Frame sourceFrame = createFrame("Source Frame", 0, 0);
Frame targetFrame = createFrame("Target Frame", 250, 250);
DragSource defaultDragSource = DragSource.getDefaultDragSource();
defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDragGestureListener());
new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDropTargetListener(targetFrame));
Robot robot = new Robot();
robot.setAutoDelay(50);
sourceFrame.toFront();
robot.waitForIdle();
Point point = getCenterPoint(sourceFrame);
robot.mouseMove(point.x, point.y);
robot.waitForIdle();
mouseDragAndDrop(robot, point, getCenterPoint(targetFrame));
long time = System.currentTimeMillis() + 200;
while (!passed) {
if (time < System.currentTimeMillis()) {
sourceFrame.dispose();
targetFrame.dispose();
throw new RuntimeException("Mouse clicked event is lost!");
}
Thread.sleep(10);
}
sourceFrame.dispose();
targetFrame.dispose();
}
use of java.awt.dnd.DropTarget in project JMRI by JMRI.
the class ControlPanelEditor method makeDataFlavors.
/**
* ************************** DnD *************************************
*/
protected void makeDataFlavors() {
// _targetPanel.setTransferHandler(new DnDIconHandler(this));
try {
_positionableDataFlavor = new DataFlavor(POSITIONABLE_FLAVOR);
_namedIconDataFlavor = new DataFlavor(ImageIndexEditor.IconDataFlavorMime);
_positionableListDataFlavor = new DataFlavor(List.class, "JComponentList");
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}
new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
}
use of java.awt.dnd.DropTarget in project JMRI by JMRI.
the class DropJLabel method accept.
private void accept(DropTargetDropEvent e, NamedIcon newIcon) {
e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
DropTarget target = (DropTarget) e.getSource();
DropJLabel label = (DropJLabel) target.getComponent();
if (log.isDebugEnabled()) {
log.debug("accept drop for " + label.getName() + ", " + newIcon.getURL());
}
if (newIcon == null || newIcon.getIconWidth() < 1 || newIcon.getIconHeight() < 1) {
label.setText(Bundle.getMessage("invisibleIcon"));
label.setForeground(Color.lightGray);
} else {
newIcon.reduceTo(100, 100, 0.2);
label.setText(null);
}
label.setIcon(newIcon);
if (newIcon != null) {
label.setToolTipText(newIcon.getName());
}
// _catalog.setBackground(label);
_iconMap.put(label.getName(), newIcon);
if (!_update) {
// only prompt for save from palette
ImageIndexEditor.indexChanged(true);
}
e.dropComplete(true);
if (log.isDebugEnabled()) {
log.debug("DropJLabel.drop COMPLETED for " + label.getName() + ", " + (newIcon != null ? newIcon.getURL() : " newIcon==null "));
}
}
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());
}
Aggregations