AutoscrollDropTargetListener implements DropTargetListener, ActionListener { @Override public synchronized void dragEnter(DropTargetDragEvent dtde) { if (!timer.isRunning()) { timer.start(); mouse = dtde.getLocation(); } } AutoscrollDropTargetListener(JComponent comp);   AutoscrollDropTargetListener(JComponent comp, Timer timer); @Override synchronized void dragEnter(DropTargetDragEvent dtde); @Override void dragOver(DropTargetDragEvent dtde); @Override synchronized void dragExit(DropTargetEvent dte); @Override synchronized void drop(DropTargetDropEvent dtde); @Override void actionPerformed(ActionEvent e); @Override void dropActionChanged(DropTargetDragEvent dtde); static final int AUTOSCROLL_BORDER_SIZE; static final int AUTOSCROLL_INITIAL_DELAY; static final int AUTOSCROLL_INTERVAL; }
@Test public void testStartDragging() { when(timer.isRunning()).thenReturn(false, true); listener.dragEnter(dragEvent); listener.dragEnter(dragEvent); verify(timer, times(1)).start(); }