本文整理汇总了Java中org.apache.pivot.wtk.Container类的典型用法代码示例。如果您正苦于以下问题:Java Container类的具体用法?Java Container怎么用?Java Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Container类属于org.apache.pivot.wtk包,在下文中一共展示了Container类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findComponentByName
import org.apache.pivot.wtk.Container; //导入依赖的package包/类
/**
* Searches a component by name in a particular component hierarchy.<p>
* A component must have a value for its <tt>name</tt> property if it's
* to be found with this method.<br/>
* This method performs a depth-first search.
*
* @param name the value of the component's <tt>name</tt> property
* @param root the root of the component hierarchy from where searching
* searching should start
* @return the component reference if found, null otherwise
*/
@Nullable
public static Component findComponentByName(@Nonnull String name, @Nonnull Container root) {
requireNonNull(root, "Argument 'root' cannot be null");
requireNonBlank(name, "Argument 'name' cannot be blank");
if (name.equals(root.getName())) {
return root;
}
for (Component comp : root) {
if (name.equals(comp.getName())) {
return comp;
}
if (comp instanceof Container) {
Component found = findComponentByName(name, (Container) comp);
if (found != null) {
return found;
}
}
}
// finally attempt calling getContent()
try {
Component component = (Component) invokeExactInstanceMethod(root, "getContent");
if (component != null) {
if (name.equals(component.getName())) {
return component;
} else if (component instanceof Container) {
return findComponentByName(name, (Container) component);
}
}
} catch (InstanceMethodInvocationException imie) {
// ignore
}
return null;
}
示例2: setParent
import org.apache.pivot.wtk.Container; //导入依赖的package包/类
@Override
protected void setParent(Container parent) {
super.setParent(parent);
if (parent == null) {
_running = false;
PlayerSimulatorApplication.getInstance().setKeyHandler(null);
} else {
startControlThread();
PlayerSimulatorApplication.getInstance().setKeyHandler(_keyHandler);
}
}