Methods Summary |
---|
public void | addElement(java.lang.Object s)adds elements to itself
(( DefaultListModel )getModel()).addElement (s.toString());
|
public void | dragDropEnd(java.awt.dnd.DragSourceDropEvent event)this message goes to DragSourceListener, informing it that the dragging
has ended
if ( event.getDropSuccess()){
removeElement();
}
|
public void | dragEnter(java.awt.dnd.DropTargetDragEvent event)is invoked when you are dragging over the DropSite
// debug messages for diagnostics
System.out.println( "dragEnter");
event.acceptDrag (DnDConstants.ACTION_MOVE);
|
public void | dragEnter(java.awt.dnd.DragSourceDragEvent event)this message goes to DragSourceListener, informing it that the dragging
has entered the DropSite
System.out.println( " dragEnter");
|
public void | dragExit(java.awt.dnd.DragSourceEvent event)this message goes to DragSourceListener, informing it that the dragging
has exited the DropSite
System.out.println( "dragExit");
|
public void | dragExit(java.awt.dnd.DropTargetEvent event)is invoked when you are exit the DropSite without dropping
System.out.println( "dragExit");
|
public void | dragGestureRecognized(java.awt.dnd.DragGestureEvent event)a drag gesture has been initiated
Object selected = getSelectedValue();
if ( selected != null ){
StringSelection text = new StringSelection( selected.toString());
// as the name suggests, starts the dragging
dragSource.startDrag (event, DragSource.DefaultMoveDrop, text, this);
} else {
System.out.println( "nothing was selected");
}
|
public void | dragOver(java.awt.dnd.DragSourceDragEvent event)this message goes to DragSourceListener, informing it that the dragging is currently
ocurring over the DropSite
System.out.println( "dragExit");
|
public void | dragOver(java.awt.dnd.DropTargetDragEvent event)is invoked when a drag operation is going on
System.out.println( "dragOver");
|
public void | drop(java.awt.dnd.DropTargetDropEvent event)a drop has occurred
try {
Transferable transferable = event.getTransferable();
// we accept only Strings
if (transferable.isDataFlavorSupported (DataFlavor.stringFlavor)){
event.acceptDrop(DnDConstants.ACTION_MOVE);
String s = (String)transferable.getTransferData ( DataFlavor.stringFlavor);
addElement( s );
event.getDropTargetContext().dropComplete(true);
}
else{
event.rejectDrop();
}
}
catch (IOException exception) {
exception.printStackTrace();
System.err.println( "Exception" + exception.getMessage());
event.rejectDrop();
}
catch (UnsupportedFlavorException ufException ) {
ufException.printStackTrace();
System.err.println( "Exception" + ufException.getMessage());
event.rejectDrop();
}
|
public void | dropActionChanged(java.awt.dnd.DragSourceDragEvent event)is invoked when the user changes the dropAction
System.out.println( "dropActionChanged");
|
public void | dropActionChanged(java.awt.dnd.DropTargetDragEvent event)is invoked if the use modifies the current drop gesture
|
public void | removeElement()removes an element from itself
(( DefaultListModel)getModel()).removeElement( getSelectedValue());
|