Search in sources :

Example 1 with AWTError

use of java.awt.AWTError in project jdk8u_jdk by JetBrains.

the class CThreading method executeOnAppKit.

public static <V> V executeOnAppKit(Callable<V> command) throws Throwable {
    if (!isAppKit()) {
        Dispatch dispatch = Dispatch.getInstance();
        if (dispatch == null) {
            throw new AWTError("Could not get Dispatch object");
        }
        FutureTask<V> future = new FutureTask<>(command);
        dispatch.getNonBlockingMainQueueExecutor().execute(future);
        try {
            return future.get();
        } catch (InterruptedException e) {
            throw new AWTError(e.getMessage());
        } catch (ExecutionException e) {
            throw e.getCause();
        }
    } else
        return command.call();
}
Also used : FutureTask(java.util.concurrent.FutureTask) Dispatch(com.apple.concurrent.Dispatch) AWTError(java.awt.AWTError) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with AWTError

use of java.awt.AWTError in project jdk8u_jdk by JetBrains.

the class X11GraphicsEnvironment method getDefaultScreenDevice.

/**
     * Returns the default screen graphics device.
     */
public GraphicsDevice getDefaultScreenDevice() {
    GraphicsDevice[] screens = getScreenDevices();
    if (screens.length == 0) {
        throw new AWTError("no screen devices");
    }
    int index = getDefaultScreenNum();
    return screens[0 < index && index < screens.length ? index : 0];
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) AWTError(java.awt.AWTError) Point(java.awt.Point)

Aggregations

AWTError (java.awt.AWTError)2 Dispatch (com.apple.concurrent.Dispatch)1 GraphicsDevice (java.awt.GraphicsDevice)1 Point (java.awt.Point)1 ExecutionException (java.util.concurrent.ExecutionException)1 FutureTask (java.util.concurrent.FutureTask)1