Beispiel #1
0
 @Override
 public void setBounds(int x, int y, int width, int height, int op) {
   super.setBounds(x, y, width, height, op);
   if (xtext != null) {
     /*
      * Fixed 6277332, 6198290:
      * the coordinates is coming (to peer): relatively to closest HW parent
      * the coordinates is setting (to textField): relatively to closest ANY parent
      * the parent of peer is target.getParent()
      * the parent of textField is the same
      * see 6277332, 6198290 for more information
      */
     int childX = x;
     int childY = y;
     Component parent = target.getParent();
     // we up to heavyweight parent in order to be sure
     // that the coordinates of the text pane is relatively to closest parent
     while (parent.isLightweight()) {
       childX -= parent.getX();
       childY -= parent.getY();
       parent = parent.getParent();
     }
     xtext.setBounds(childX, childY, width, height);
     xtext.validate();
   }
 }
Beispiel #2
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);
    }
  }
 /**
  * Checks if the component is in an EmbeddedFrame. If so, returns the applet found in the
  * hierarchy or null if not found.
  *
  * @return the parent applet or {@ null}
  * @since 1.6
  */
 public static Applet getAppletIfAncestorOf(Component comp) {
   Container parent = comp.getParent();
   Applet applet = null;
   while (parent != null && !(parent instanceof EmbeddedFrame)) {
     if (parent instanceof Applet) {
       applet = (Applet) parent;
     }
     parent = parent.getParent();
   }
   return parent == null ? null : applet;
 }
  // 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;
  }
  public void show(Event e) {
    Component origin = (Component) e.target;
    WComponentPeer peer = (WComponentPeer) WToolkit.targetToPeer(origin);
    if (peer == null) {
      // A failure to map the peer should only happen for a
      // lightweight component, then find the actual native parent from
      // that component.  The event coorinates are going to have to be
      // remapped as well.
      Component nativeOrigin = WToolkit.getNativeContainer(origin);
      e.target = nativeOrigin;

      // remove the event coordinates
      for (Component c = origin; c != nativeOrigin; c = c.getParent()) {
        Point p = c.getLocation();
        e.x += p.x;
        e.y += p.y;
      }
    }
    _show(e);
  }
Beispiel #6
0
 Window getTopLevel(Component comp) {
   while (comp != null && !(comp instanceof Window)) {
     comp = comp.getParent();
   }
   return (Window) comp;
 }