Example usage for java.awt Image getClass

List of usage examples for java.awt Image getClass

Introduction

In this page you can find the example usage for java.awt Image getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:Main.java

public static BufferedImage toBufferedImageUnchecked(Image awtImage) {
    Method getBufferedImage = null;
    try {/* w w  w . j a  v a  2s  .  c  o m*/
        getBufferedImage = awtImage.getClass().getMethod("getBufferedImage");
    } catch (NoSuchMethodException | SecurityException e) {
        throw new RuntimeException(e);
    }
    BufferedImage bufferedImage = null;
    try {
        bufferedImage = (BufferedImage) getBufferedImage.invoke(awtImage);
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        e.printStackTrace();
    }
    return bufferedImage;
}