View Javadoc
1 /* 2 * Created on Nov 1, 2003 3 */ 4 package portaview.dnd; 5 6 import java.awt.datatransfer.DataFlavor; 7 import java.awt.datatransfer.Transferable; 8 import java.awt.datatransfer.UnsupportedFlavorException; 9 import java.io.IOException; 10 11 import javax.swing.JComponent; 12 13 /*** 14 * Transfer object for the drag and drop the album to the portaview. 15 * @author William Lee 16 */ 17 public class AlbumTransfer implements Transferable 18 { 19 public static DataFlavor FLAVOUR; 20 protected JComponent source; 21 22 static 23 { 24 try 25 { 26 FLAVOUR = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType); 27 } 28 catch (Exception e) 29 { 30 e.printStackTrace(); 31 } 32 } 33 34 public AlbumTransfer(JComponent src) 35 { 36 this.source = src; 37 } 38 39 /*** 40 * Returns the default data flavor (local jvm object). 41 * @see java.awt.datatransfer.Transferable#getTransferDataFlavors() 42 */ 43 public DataFlavor[] getTransferDataFlavors() 44 { 45 return new DataFlavor[] {FLAVOUR}; 46 } 47 48 /*** 49 * Returns true if the flavor is the jvm local MIME type. 50 * @see java.awt.datatransfer.Transferable#isDataFlavorSupported(java.awt.datatransfer.DataFlavor) 51 */ 52 public boolean isDataFlavorSupported(DataFlavor flavor) 53 { 54 return FLAVOUR.equals(flavor); 55 } 56 57 /*** 58 * Returns the transfer data. 59 * @see java.awt.datatransfer.Transferable#getTransferData(java.awt.datatransfer.DataFlavor) 60 */ 61 public Object getTransferData(DataFlavor flavor) 62 throws UnsupportedFlavorException, IOException 63 { 64 if (!isDataFlavorSupported(flavor)) 65 throw new UnsupportedFlavorException(flavor); 66 return this; 67 } 68 69 /*** 70 * @return the source for this drag and drop event. 71 */ 72 public JComponent getSource() 73 { 74 return source; 75 } 76 77 /*** 78 * Sets the source component for this event. 79 * @param component the source for the drag and drop. 80 */ 81 public void setSource(JComponent component) 82 { 83 source = component; 84 } 85 86 }

This page was automatically generated by Maven