// java.awt.Toolkit#getNativeContainer() is not available
  //  from this package
  private WComponentPeer getNearestNativePeer(Component comp) {
    if (comp == null) return null;

    ComponentPeer peer = comp.getPeer();
    if (peer == null) return null;

    while (peer instanceof java.awt.peer.LightweightPeer) {
      comp = comp.getParent();
      if (comp == null) return null;
      peer = comp.getPeer();
      if (peer == null) return null;
    }

    if (peer instanceof WComponentPeer) return (WComponentPeer) peer;
    else return null;
  }
 @SuppressWarnings("deprecation")
 private void replaceSurfaceDataRecursively(Component c) {
   if (c instanceof Container) {
     for (Component child : ((Container) c).getComponents()) {
       replaceSurfaceDataRecursively(child);
     }
   }
   ComponentPeer cp = c.getPeer();
   if (cp instanceof WComponentPeer) {
     ((WComponentPeer) cp).replaceSurfaceDataLater();
   }
 }
Beispiel #3
0
  /**
   * Returns the native container object of the specified component. This method is necessary
   * because the parent component might be a lightweight component.
   *
   * @param component The component to fetch the native container for.
   * @return The native container object for this component.
   */
  protected static Container getNativeContainer(Component component) {
    component = component.getParent();

    for (; ; ) {
      if (component == null) return (null);

      if (!(component instanceof Container)) {
        component = component.getParent();
        continue;
      }

      if (component.getPeer() instanceof LightweightPeer) {
        component = component.getParent();
        continue;
      }

      return ((Container) component);
    }
  }