Java Example Program/ Sample Source Code
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.FlavorTable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class GetNativesForFlavorExample implements FlavorTable {
public Map<DataFlavor, String> getNativesForFlavors(DataFlavor[] flavors) {
Map<DataFlavor, String> nativesMap = new HashMap<DataFlavor, String>();
DataFlavor dataFlavor = new DataFlavor(java.awt.TextField.class,
"AWT TextField");
nativesMap.put(dataFlavor, "dataFlavor");
return nativesMap;
}
public Map<String, DataFlavor> getFlavorsForNatives(String[] natives) {
Map<String, DataFlavor> nativesMap = new HashMap<String, DataFlavor>();
DataFlavor dataFlavor = new DataFlavor("text/plain; charset=ASCII",
"Plain ASCII text");
nativesMap.put("dataFlavor", dataFlavor);
return nativesMap;
}
@Override
public List<String> getNativesForFlavor(DataFlavor flav) {
List<String> nativesList = new ArrayList<String>();
nativesList.add("values");
return nativesList;
}
@Override
public List<DataFlavor> getFlavorsForNative(String nat) {
List<DataFlavor> nativesList = new ArrayList<DataFlavor>();
DataFlavor dataFlavor = new DataFlavor("text/plain; charset=ASCII",
"Plain ASCII text");
nativesList.add(dataFlavor);
return nativesList;
}
} |
|
|