當前位置: 首頁>>代碼示例>>Java>>正文


Java DataFlavor.getMimeType方法代碼示例

本文整理匯總了Java中java.awt.datatransfer.DataFlavor.getMimeType方法的典型用法代碼示例。如果您正苦於以下問題:Java DataFlavor.getMimeType方法的具體用法?Java DataFlavor.getMimeType怎麽用?Java DataFlavor.getMimeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.datatransfer.DataFlavor的用法示例。


在下文中一共展示了DataFlavor.getMimeType方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: verifyNewMappings

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public void verifyNewMappings() {
    // Enumerate through all DataFlavors
    for (Enumeration e = hashVerify.keys() ; e.hasMoreElements() ;) {
        DataFlavor key = (DataFlavor)e.nextElement();

        java.util.List listNatives = flavorMap.getNativesForFlavor(key);
        Vector vectorFlavors = new Vector(listNatives);

        // Compare the list of Natives
        if ( !vectorFlavors.equals(hashVerify.get(key))) {
            throw new RuntimeException("\n*** Error in verifyNewMappings()" +
                "\nmethod1: setNativesForFlavor(DataFlavor flav, String[] natives)" +
                "\nmethod2: List getNativesForFlavor(DataFlavor flav)" +
                "\nDataFlavor: " + key.getMimeType() +
                "\nThe Returned List did not match the original set of Natives.");
        }
    }
    System.out.println("*** DataFlavor size = " + hashVerify.size());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:SetDataFlavorsTest.java

示例2: initMappings

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public void initMappings() throws Exception {
    //initialize mapping variables used in this test
    //create a DataFlavor from Button class
    test_flavor1 = new DataFlavor(Class.forName("java.awt.Button"), "Button");

    //create an Encoded String native using Button class MIME Type
    String buttonMIME = test_flavor1.getMimeType();
    test_encoded = SystemFlavorMap.encodeJavaMIMEType(buttonMIME);

    //create a DataFlavor from the Encoded String native
    test_flavor2 = SystemFlavorMap.decodeDataFlavor(test_encoded);

    //create and initialize DataFlavor arrays
    test_flavors_set = new DataFlavor[] {test_flavor1};

    //create and initialize String native arrays
    test_natives_set = new String[] {test_encoded};
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:GetNativesForNewFlavorTest.java

示例3: initMappings

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public void initMappings() throws Exception {
   //initialize mapping variables used in this test
  //create an Unencoded String native
  test_native1 = "TEST1";

  //create a DataFlavor from Button class
  test_flavor1 = new DataFlavor(Class.forName("java.awt.Button"), "Button");

  //create an Encoded String native using Button class MIME Type
  String buttonMIME = test_flavor1.getMimeType();
  test_encoded = SystemFlavorMap.encodeJavaMIMEType(buttonMIME);

  //create a DataFlavor from the Encoded String native
  test_flavor2 = SystemFlavorMap.decodeDataFlavor(test_encoded);

  //create and initialize DataFlavor arrays
  test_flavors_set = new DataFlavor[] {test_flavor2};

  //create and initialize String native arrays
  test_natives_set = new String[] {test_encoded};
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:GetFlavorsForNewNativeTest.java

示例4: verifyListDataFlavorEntries

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public void verifyListDataFlavorEntries() {
    // Enumerate through all natives
    for (Enumeration e = hashNatives.keys() ; e.hasMoreElements() ;) {
        String key = (String)e.nextElement();

        // SystemFlavorMap preferred value
        DataFlavor value = (DataFlavor)hashNatives.get(key);

        java.util.List listFlavors = flavorMap.getFlavorsForNative(key);
        Vector vectorFlavors = new Vector(listFlavors);

        // First element should be preferred value
        DataFlavor prefFlavor = (DataFlavor)vectorFlavors.firstElement();
        if ( value != prefFlavor ) {
            throw new RuntimeException("\n*** Error in verifyListDataFlavorEntries()" +
                "\nAPI Test: List getFlavorsForNative(String nat)" +
                "\native: " + key +
                "\nSystemFlavorMap preferred native: " + value.getMimeType() +
                "\nList first entry: " + prefFlavor.getMimeType() +
                "\nTest failed because List first entry does not match preferred");
        }
    }
    System.out.println("*** native size = " + hashNatives.size());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:ManyFlavorMapTest.java

示例5: verifyListNativeEntries

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public void verifyListNativeEntries() {
    // Enumerate through all DataFlavors
    for (Enumeration e = hashFlavors.keys() ; e.hasMoreElements() ;) {
        DataFlavor key = (DataFlavor)e.nextElement();

        // SystemFlavorMap preferred value
        String value = (String)hashFlavors.get(key);

        java.util.List listNatives = flavorMap.getNativesForFlavor(key);
        Vector vectorNatives = new Vector(listNatives);

        // First element should be preferred value
        String prefNative = (String)vectorNatives.firstElement();
        if ( value != prefNative ) {
            throw new RuntimeException("\n*** Error in verifyListNativeEntries()" +
                "\nAPI Test: List getNativesForFlavor(DataFlavor flav)" +
                "\nDataFlavor: " + key.getMimeType() +
                "\nSystemFlavorMap preferred native: " + value +
                "\nList first entry: " + prefNative +
                "\nTest failed because List first entry does not match preferred");
        }
    }
    System.out.println("*** DataFlavor size = " + hashFlavors.size());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:ManyFlavorMapTest.java

示例6: main

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public static void main(String[] args) {
    DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator();
    DataFlavor flavor1 = DataFlavor.imageFlavor;
    DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor;
    if (comparator.compare(flavor1, flavor2) == 0) {
        throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() +
            " should not be equal");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:10,代碼來源:DataFlavorComparatorTest.java

示例7: verifyNewMappings

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public boolean verifyNewMappings() {
    boolean result = true;

    // Enumerate through all DataFlavors
    for (Enumeration e = hashVerify.keys() ; e.hasMoreElements() ;) {
        DataFlavor key = (DataFlavor)e.nextElement();

        java.util.List listNatives = flavorMap.getNativesForFlavor(key);
        Vector vectorNatives = new Vector(listNatives);

        // Compare the list of Natives
        //Next line changed by Kanishk to comply with bug 4696522
        //if ( !vectorNatives.equals((Vector)hashVerify.get(key))) {
        if ( !(vectorNatives.containsAll((Vector)hashVerify.get(key)) && ((Vector)hashVerify.get(key)).containsAll(vectorNatives))) {
            throw new RuntimeException("\n*** Error in verifyNewMappings()" +
                "\nmethod1: addUnencodedNativeForFlavor(DataFlavor flav, String nat)"  +
                "\nmethod2: List getNativesForFlavor(DataFlavor flav)" +
                "\nDataFlavor: " + key.getMimeType() +
                "\nAfter adding several mappings with addUnencodedNativeForFlavor," +
                "\nthe returned list did not match the mappings that were added." +
                "\nThe mapping was not included in the list.");
        }
    }
    System.out.println("*** DataFlavor size = " + hashVerify.size());
    System.out.println("*** verifyNewMappings result: " + result + "\n");
    return result;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:AddNativeTest.java

示例8: main

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public static void main(String[] args) {
    Comparator<DataFlavor> comparator = DataFlavorUtil.getDataFlavorComparator();
    DataFlavor flavor1 = DataFlavor.imageFlavor;
    DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor;
    if (comparator.compare(flavor1, flavor2) == 0) {
        throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() +
            " should not be equal");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:DataFlavorComparatorTest.java


注:本文中的java.awt.datatransfer.DataFlavor.getMimeType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。