当前位置: 首页>>代码示例>>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;未经允许,请勿转载。