Java Clipboard Image isImageDataFlavor(Clipboard clip)

Here you can find the source of isImageDataFlavor(Clipboard clip)

Description

test if data flavor has mime type x-java-image

License

Open Source License

Declaration

public static boolean isImageDataFlavor(Clipboard clip) 

Method Source Code

//package com.java2s;
/*/*from  w w  w.j  av  a2s  .  com*/
 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description:
 *
 */

import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;

import java.io.InputStream;

public class Main {
    /**
     * test if data flavor has mime type x-java-image
     */
    public static boolean isImageDataFlavor(Clipboard clip) {
        DataFlavor fl[] = clip.getAvailableDataFlavors();
        if (fl.length > 0) {
            DataFlavor f = fl[0];
            if ("image".equals(f.getPrimaryType())) {
                if (InputStream.class.getName().equals(
                        f.getDefaultRepresentationClassAsString()))
                    return true;
            }
        }
        return false;
    }
}

Related

  1. canPasteImageFromClipboard()
  2. getClipboardImage()
  3. getClipboardImage()
  4. getClipboardImage()
  5. getFilenameFromClipboard(Clipboard clip)
  6. setClipboardImage(final Image image)
  7. setClipboardImage(final Image image)