com.google.gwt.user.client.ui.Widget.removeFromParent()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中com.google.gwt.user.client.ui.Widget.removeFromParent()方法的一些代码示例,展示了Widget.removeFromParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Widget.removeFromParent()方法的具体详情如下:
包路径:com.google.gwt.user.client.ui.Widget
类名称:Widget
方法名:removeFromParent

Widget.removeFromParent介绍

[英]Removes this widget from its parent widget, if one exists.

If it has no parent, this method does nothing. If it is a "root" widget (meaning it's been added to the detach list via RootPanel#detachOnWindowClose(Widget)), it will be removed from the detached immediately. This makes it possible for Composites and Panels to adopt root widgets.
[中]从父窗口小部件(如果存在)中删除此窗口小部件。
如果没有父对象,则此方法不执行任何操作。如果它是一个“根”小部件(意味着它已通过RootPanel#detachOnWindowClose(小部件)添加到分离列表),它将立即从分离列表中删除。这使得复合材料和面板可以采用根部件。

代码示例

代码示例来源:origin: kaaproject/kaa

/**
 * Insert a widget before the specified widget. If the widget is already a
 * child of this panel, this method behaves as though {@link #remove(Widget)}
 * had already been called.
 *
 * @param widget the widget to be added
 * @param before the widget before which to insert the new child, or <code>null</code> to append
 */
public void insert(Widget widget, Widget before) {
 assertIsChild(before);
 // Detach new child.
 widget.removeFromParent();
 // Logical attach.
 WidgetCollection children = getChildren();
 if (before == null) {
  children.add(widget);
 } else {
  int index = children.indexOf(before);
  children.insert(widget, index);
 }
 // Physical attach.
 Layer layer = layout.attachChild(widget.getElement(), (before != null)
   ? before.getElement() : null, widget);
 setWidgetVisible(widget, layer, false);
 widget.setLayoutData(layer);
 // Adopt.
 adopt(widget);
 // Update the layout.
 animate(0);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

public void remove() {
 if (lastIndex < 0) {
  throw new IllegalStateException();
 }
 Widget w = widgetList.get(lastIndex);
 assert (w.getParent() instanceof HTMLTable);
 w.removeFromParent();
 lastIndex = -1;
}

代码示例来源:origin: com.google.gwt/gwt-servlet

public void remove() {
  if (index < 0 || index >= widgetCount) {
   throw new IllegalStateException();
  }
  IsWidget w = provider.get(index);
  if (w == null) {
   throw new IllegalStateException("Widget was already removed.");
  }
  w.asWidget().removeFromParent();
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * @deprecated Call and override {@link #add(Widget, Element)} instead.
 */
@Deprecated
protected void add(Widget child, com.google.gwt.user.client.Element container) {
 // Detach new child.
 child.removeFromParent();
 // Logical attach.
 getChildren().add(child);
 // Physical attach.
 DOM.appendChild(container, child.getElement());
 // Adopt.
 adopt(child);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Inserts a child widget at the specified position before the specified
 * index. Setting a position of <code>(-1, -1)</code> will cause the child
 * widget to be positioned statically. If the widget is already a child of
 * this panel, it will be moved to the specified index.
 * 
 * @param w the child widget to be inserted
 * @param left the widget's left position
 * @param top the widget's top position
 * @param beforeIndex the index before which it will be inserted
 * @throws IndexOutOfBoundsException if <code>beforeIndex</code> is out of
 *           range
 */
public void insert(Widget w, int left, int top, int beforeIndex) {
 // In order to avoid the potential for a flicker effect, it is necessary
 // to set the position of the widget before adding it to the AbsolutePanel.
 // The Widget should be removed from its parent before any positional
 // changes are made to prevent flickering.
 w.removeFromParent();
 setWidgetPositionImpl(w, left, top);
 insert(w, beforeIndex);
 verifyPositionNotStatic(w);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Adds a child widget to the panel, replacing the HTML element.
 *
 * @param widget the widget to be added
 * @param toReplace the element to be replaced by the widget
 * @deprecated use {@link #addAndReplaceElement(Widget, Element)}
 */
@Deprecated
public void addAndReplaceElement(Widget widget,
  com.google.gwt.user.client.Element toReplace) {
 // Logic pulled from super.add(), replacing the element rather than adding.
 widget.removeFromParent();
 getChildren().add(widget);
 toReplace.getParentNode().replaceChild(widget.getElement(), toReplace);
 adopt(widget);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Adds a widget to the panel at the specified position. Setting a position of
 * <code>(-1, -1)</code> will cause the child widget to be positioned
 * statically.
 * 
 * @param w the widget to be added
 * @param left the widget's left position
 * @param top the widget's top position
 */
public void add(Widget w, int left, int top) {
 // In order to avoid the potential for a flicker effect, it is necessary
 // to set the position of the widget before adding it to the AbsolutePanel.
 // The Widget should be removed from its parent before any positional
 // changes are made to prevent flickering.
 w.removeFromParent();
 int beforeIndex = getWidgetCount();
 setWidgetPositionImpl(w, left, top);
 insert(w, beforeIndex);
 verifyPositionNotStatic(w);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

widget.removeFromParent();

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Sets this panel's widget. Any existing child widget will be removed.
 *
 * @param w the panel's new widget, or <code>null</code> to clear the panel
 */
public void setWidget(Widget w) {
 // Validate
 if (w == widget) {
  return;
 }
 // Detach new child.
 if (w != null) {
  w.removeFromParent();
 }
 // Remove old child.
 if (widget != null) {
  remove(widget);
 }
 // Logical attach.
 widget = w;
 if (w != null) {
  // Physical attach.
  DOM.appendChild(getContainerElement(), widget.getElement());
  adopt(w);
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * @deprecated Call and override {@link insert(Widget, Element, int, boolean)} instead.
 */
@Deprecated
protected void insert(Widget child, com.google.gwt.user.client.Element container,
  int beforeIndex, boolean domInsert) {
 // Validate index; adjust if the widget is already a child of this panel.
 beforeIndex = adjustIndex(child, beforeIndex);
 // Detach new child.
 child.removeFromParent();
 // Logical attach.
 getChildren().insert(child, beforeIndex);
 // Physical attach.
 if (domInsert) {
  DOM.insertChild(container, child.getElement(), beforeIndex);
 } else {
  DOM.appendChild(container, child.getElement());
 }
 // Adopt.
 adopt(child);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

public boolean remove(int index) {
 if ((index < 0) || (index >= getWidgetCount())) {
  return false;
 }
 Widget child = getWidget(index);
 tabBar.remove(index);
 deckPanel.removeProtected(child);
 child.removeStyleName(CONTENT_STYLE);
 Tab tab = tabs.remove(index);
 tab.getWidget().removeFromParent();
 if (index == selectedIndex) {
  // If the selected tab is being removed, select the first tab (if there
  // is one).
  selectedIndex = -1;
  if (getWidgetCount() > 0) {
   selectTab(0);
  }
 } else if (index < selectedIndex) {
  // If the selectedIndex is greater than the one being removed, it needs
  // to be adjusted.
  --selectedIndex;
 }
 return true;
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Add a widget to the panel in the specified container. Note that this method
 * does not do the logical attach.
 * 
 * @param w the widget to add
 * @param toReplace the widget to replace
 * @param container the container in which to place the widget
 */
private void add(Widget w, Widget toReplace, Element container) {
 // Validate.
 if (w == toReplace) {
  return;
 }
 // Detach new child.
 if (w != null) {
  w.removeFromParent();
 }
 // Remove old child.
 if (toReplace != null) {
  remove(toReplace);
 }
 if (w != null) {
  // Physical attach.
  container.appendChild(w.getElement());
  container.getStyle().clearDisplay();
  adopt(w);
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

widget.removeFromParent();

代码示例来源:origin: com.google.gwt/gwt-servlet

w.removeFromParent();

代码示例来源:origin: com.google.gwt/gwt-servlet

widget.removeFromParent();

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Add a widget to the panel in the specified layer. Note that this method
 * does not do the logical attach.
 * 
 * @param w the widget to add, or null to clear the widget
 * @param toReplace the widget to replace
 * @param layer the layer in which the existing widget is placed
 * @return the layer in which the new widget is placed, or null if no widget
 */
private Layer add(IsWidget w, IsWidget toReplace, Layer layer) {
 // Validate.
 if (w == toReplace) {
  return layer;
 }
 // Detach new child.
 if (w != null) {
  w.asWidget().removeFromParent();
 }
 // Remove old child.
 if (toReplace != null) {
  remove(toReplace);
 }
 Layer toRet = null;
 if (w != null) {
  // Physical attach.
  toRet = layout.attachChild(w.asWidget().getElement());
  adopt(w.asWidget());
 }
 return toRet;
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
public void setWidget(Widget w) {
 // Validate
 if (w == widget) {
  return;
 }
 // Detach new child.
 if (w != null) {
  w.removeFromParent();
 }
 // Remove old child.
 if (widget != null) {
  remove(widget);
 }
 // Logical attach.
 widget = w;
 if (w != null) {
  // Physical attach.
  layer = layout.attachChild(widget.getElement(), widget);
  layer.setTopHeight(0.0, Unit.PX, 100.0, Unit.PCT);
  layer.setLeftWidth(0.0, Unit.PX, 100.0, Unit.PCT);
  adopt(w);
  // Update the layout.
  layout.layout();
  scheduleResize();
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
public void setWidget(Widget w) {
 // Validate
 if (w == widget) {
  return;
 }
 // Detach new child.
 if (w != null) {
  w.removeFromParent();
 }
 // Remove old child.
 if (widget != null) {
  remove(widget);
 }
 // Logical attach.
 widget = w;
 if (w != null) {
  // Physical attach.
  layer = layout.attachChild(widget.getElement(), widget);
  layer.setTopHeight(0.0, Unit.PX, 100.0, Unit.PCT);
  layer.setLeftWidth(0.0, Unit.PX, 100.0, Unit.PCT);
  adopt(w);
  // Update the layout.
  layout.layout();
  onResize();
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

widget.removeFromParent();

代码示例来源:origin: com.google.gwt/gwt-servlet

captionWidget.asWidget().removeFromParent();
caption = captionWidget;

相关文章