import util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.dnd.*;

public class IconButton extends JButton implements DragSourceListener, DragGestureListener {

    DragSource dragSource;
    
    public IconButton() {
	// Set up appearance.
	setBorderPainted(false);
	setContentAreaFilled(false);
	setFocusPainted(false);
	setSize(32,32);
	setMargin(new Insets(0,0,0,0));
	setIcon(new ImageIcon("folder.gif"));
	setPressedIcon(new ImageIcon("selectedfolder.gif"));
  	setSelectedIcon(new ImageIcon("selectedfolder.gif")); // not used yet.
  
	// Set up DND
	dragSource = DragSource.getDefaultDragSource();
	dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this);
    }
        
    /** Interface DragGestureListener */
    public void dragGestureRecognized(DragGestureEvent dge) {
	Debug.print("Drag gesture recognized");
	dge.startDrag(DragSource.DefaultMoveDrop,  // initial cursor
		      new StringSelection("Reposition me"), // Transferable to pass
		      this); // DragSourceListener
    }

    /** Interface DragSourceListener (5 methods) */
    public void dragDropEnd(DragSourceDropEvent DragSourceDropEvent){}
    public void dragEnter(DragSourceDragEvent DragSourceDragEvent){}
    public void dragExit(DragSourceEvent DragSourceEvent){}
    public void dragOver(DragSourceDragEvent DragSourceDragEvent){}
    public void dropActionChanged(DragSourceDragEvent DragSourceDragEvent){}
    
}
