static long getComponentID(Object o) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException("No native windows when headless"); } Component c = (Component)o; if (c.isLightweight()) { throw new IllegalArgumentException("Component must be heavyweight"); } if (!c.isDisplayable()) throw new IllegalStateException("Component must be displayable"); // On X11 VMs prior to 1.5, the window must be visible if (Platform.isX11() && System.getProperty("java.version").startsWith("1.4")) { if (!c.isVisible()) { throw new IllegalStateException("Component must be visible"); } } // By this point, we're certain that Toolkit.loadLibraries() has // been called, thus avoiding AWT/JAWT link errors // (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6539705). return Native.getWindowHandle0(c); } }
static long getComponentID(Object o) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException("No native windows when headless"); } Component c = (Component)o; if (c.isLightweight()) { throw new IllegalArgumentException("Component must be heavyweight"); } if (!c.isDisplayable()) throw new IllegalStateException("Component must be displayable"); // On X11 VMs prior to 1.5, the window must be visible if (Platform.isX11() && System.getProperty("java.version").startsWith("1.4")) { if (!c.isVisible()) { throw new IllegalStateException("Component must be visible"); } } // By this point, we're certain that Toolkit.loadLibraries() has // been called, thus avoiding AWT/JAWT link errors // (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6539705). return Native.getWindowHandle0(c); } }
/** Utility method to get the native window ID for a heavyweight Java * {@link Component} as a <code>long</code> value. * This method is primarily for X11-based systems, which use an opaque * <code>XID</code> (usually <code>long int</code>) to identify windows. * @throws HeadlessException if the current VM is running headless */ public static long getComponentID(Component c) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException("No native windows when headless"); } if (c.isLightweight()) { throw new IllegalArgumentException("Component must be heavyweight"); } if (!c.isDisplayable()) throw new IllegalStateException("Component must be displayable"); // On X11 VMs prior to 1.5, the window must be visible if (Platform.isX11() && System.getProperty("java.version").matches("^1\\.4\\..*")) { if (!c.isVisible()) { throw new IllegalStateException("Component must be visible"); } } // By this point, we're certain that Toolkit.loadLibraries() has // been called, thus avoiding AWT/JAWT link errors // (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6539705). return getWindowHandle0(c); }
/** * Get global hotkey provider for current platform * * @param useSwingEventQueue whether the provider should be using Swing Event queue or a regular thread * @return new instance of Provider, or null if platform is not supported * @see X11Provider * @see WindowsProvider * @see CarbonProvider */ public static Provider getCurrentProvider(boolean useSwingEventQueue) { Provider provider; if (Platform.isX11()) { provider = new X11Provider(); } else if (Platform.isWindows()) { provider = new WindowsProvider(); } else if (Platform.isMac()) { provider = new CarbonProvider(); } else { LOGGER.warn("No suitable provider for " + System.getProperty("os.name")); return null; } provider.setUseSwingEventQueue(useSwingEventQueue); provider.init(); return provider; }
/** * Get global hotkey provider for current platform * * @param useSwingEventQueue whether the provider should be using Swing Event queue or a regular thread * @return new instance of Provider, or null if platform is not supported * @see X11Provider * @see WindowsProvider * @see CarbonProvider */ public static Provider getCurrentProvider(boolean useSwingEventQueue) { Provider provider; if (Platform.isX11()) { provider = new X11Provider(); } else if (Platform.isWindows()) { provider = new WindowsProvider(); } else if (Platform.isMac()) { provider = new CarbonProvider(); } else { LOGGER.warn("No suitable provider for " + System.getProperty("os.name")); return null; } provider.setUseSwingEventQueue(useSwingEventQueue); provider.init(); return provider; }