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); }