本文整理汇总了Java中com.codename1.ui.Component.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getParent方法的具体用法?Java Component.getParent怎么用?Java Component.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codename1.ui.Component
的用法示例。
在下文中一共展示了Component.getParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scrollToElement
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* Scrolls the HTMLComponent to the specified element
*
* @param element The element to scroll to (must be contained in the document)
* @param animate true to animate the scrolling, false otherwise
* @throws IllegalArgumentException if the element is not contained in the current document.
*/
public void scrollToElement(HTMLElement element,boolean animate) {
if (!pageLoading()) {
if (!document.contains(element)) {
throw new IllegalArgumentException("The specified element is not contained in the current document.");
}
Vector v=element.getUi();
if ((v!=null) && (v.size()>0)) {
Component cmp=((Component)v.firstElement());
if (cmp!=null) {
Container parent=cmp.getParent();
int y=cmp.getY();
while ((parent!=null) && (parent!=this)) {
y+=parent.getY();
parent=parent.getParent();
}
scrollTo(y , animate);
}
}
} else {
throw new IllegalStateException("Page is still loading");
}
}
示例2: setComponentConstraintsImpl
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* Sets the component constraint for the component that already must be
* handled by this layout manager.
* <p>
* See the class JavaDocs for information on how this string is formatted.
*
* @param constr The component constraints as a String or
* {@link net.miginfocom.layout.CC}. <code>null</code> is ok.
* @param comp The component to set the constraints for.
* @param noCheck Doe not check if the component is handled if true
* @throws RuntimeException if the constraint was not valid.
* @throws IllegalArgumentException If the component is not handling the
* component.
*/
private void setComponentConstraintsImpl(Component comp, Object constr, boolean noCheck) {
Container parent = comp.getParent();
if (noCheck == false && scrConstrMap.containsKey(comp) == false) {
throw new IllegalArgumentException("Component must already be added to parent!");
}
ComponentWrapper cw = new CodenameOneMiGComponentWrapper(comp);
if (constr == null || constr instanceof String) {
String cStr = ConstraintParser.prepare((String) constr);
scrConstrMap.put(comp, constr);
ccMap.put(cw, ConstraintParser.parseComponentConstraint(cStr));
} else if (constr instanceof CC) {
scrConstrMap.put(comp, constr);
ccMap.put(cw, (CC) constr);
} else {
throw new IllegalArgumentException("Constraint must be String or ComponentConstraint: " + constr.getClass().toString());
}
dirty = true;
}
示例3: addLayoutComponent
import com.codename1.ui.Component; //导入方法依赖的package包/类
public void addLayoutComponent(Object constraints, Component comp, Container c) {
GridBagConstraints cons;
if (constraints != null) {
if (!(constraints instanceof GridBagConstraints)) {
throw new IllegalArgumentException("AddLayoutComponent: constraint object must be GridBagConstraints"); //$NON-NLS-1$
}
cons = (GridBagConstraints) constraints;
} else {
if (comptable.containsKey(comp)) {
// don't replace constraints with default ones
return;
}
cons = defaultConstraints;
}
/*try {
//cons.verify();
} catch (IllegalArgumentException e) {
// awt.81=AddLayoutComponent: {0}
throw new IllegalArgumentException("AddLayoutComponent: " + e.getMessage()); //$NON-NLS-1$
}*/
GridBagConstraints consClone = (GridBagConstraints) cons.clone();
comptable.put(comp, consClone);
Container parent = comp.getParent();
updateParentInfo(parent, consClone);
}
示例4: initCompsArray
import com.codename1.ui.Component; //导入方法依赖的package包/类
private Dimension initCompsArray(Container parent, Component[] components) {
int maxW = 0;
int maxH = 0;
int i = 0;
for (Component comp : comptable.keySet()) {
GridBagConstraints cons = comptable.get(comp);
if ((comp.getParent() == parent) && comp.isVisible()) {
components[i++] = comp;
}
if ((cons.gridx != GridBagConstraints.RELATIVE)
&& (cons.gridy != GridBagConstraints.RELATIVE)) {
maxW = Math.max(maxW, cons.gridx + cons.gridwidth);
maxH = Math.max(maxH, cons.gridy + cons.gridheight);
}
}
return new Dimension(maxW, maxH);
}
示例5: calcPreferredValues
import com.codename1.ui.Component; //导入方法依赖的package包/类
private void calcPreferredValues(Component cmp) {
if (tmpLaidOut.contains(cmp)) {
return;
}
tmpLaidOut.add(cmp);
LayeredLayoutConstraint constraint = (LayeredLayoutConstraint) getComponentConstraint(cmp);
if (constraint != null) {
constraint.fixDependencies(cmp.getParent());
for (LayeredLayoutConstraint.Inset inset : constraint.insets) {
if (inset.referenceComponent != null && inset.referenceComponent.getParent() == cmp.getParent()) {
calcPreferredValues(inset.referenceComponent);
}
inset.calcPreferredValue(cmp.getParent(), cmp);
}
}
}
示例6: replace
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* Removes an existing component replacing it with the specified component.
*
* @param existingComponent the Component that should be removed and
* replaced with newComponent
* @param newComponent the Component to put in existingComponents place
* @throws IllegalArgumentException is either of the Components are null or
* if existingComponent is not being managed by this layout manager
*/
public void replace(Component existingComponent, Component newComponent) {
if (existingComponent == null || newComponent == null) {
throw new IllegalArgumentException("Components must be non-null");
}
// Make sure all the components have been registered, otherwise we may
// not update the correct Springs.
if (springsChanged) {
registerComponents(horizontalGroup, HORIZONTAL);
registerComponents(verticalGroup, VERTICAL);
}
ComponentInfo info = (ComponentInfo)componentInfos.
remove(existingComponent);
if (info == null) {
throw new IllegalArgumentException("Component must already exist");
}
host.removeComponent(existingComponent);
if (newComponent.getParent() != host) {
host.addComponent(newComponent);
}
info.setComponent(newComponent);
componentInfos.put(newComponent, info);
invalidateHost();
}
示例7: hideComponent
import com.codename1.ui.Component; //导入方法依赖的package包/类
public void hideComponent(Component c)
{
c.setHeight(0);
c.setPreferredH(0);
if (c.getParent() != null) {
c.getParent().revalidate();
}
c.setVisible(false);
}
示例8: getVisibleRect
import com.codename1.ui.Component; //导入方法依赖的package包/类
private static com.codename1.ui.geom.Rectangle getVisibleRect(Component c) {
com.codename1.ui.geom.Rectangle r = new com.codename1.ui.geom.Rectangle(c.getAbsoluteX() + c.getScrollX(), c.getAbsoluteY() + c.getScrollY(), c.getWidth(), c.getHeight());
while ((c = c.getParent()) != null) {
com.codename1.ui.geom.Rectangle.intersection(r.getX(), r.getY(), r.getWidth(), r.getHeight(),
c.getAbsoluteX() + c.getScrollX(), c.getAbsoluteY() + c.getScrollY(), c.getWidth(), c.getHeight(),
r);
}
return r;
}
示例9: isScrollableParent
import com.codename1.ui.Component; //导入方法依赖的package包/类
private static boolean isScrollableParent(Component c){
Container p = c.getParent();
Font f = c.getStyle().getFont();
float pixelSize = f == null ? Display.getInstance().convertToPixels(4) : f.getPixelSize();
while( p != null){
if(p.isScrollableY() && p.getAbsoluteY() + p.getScrollY() < Display.getInstance().getDisplayHeight() / 2 - pixelSize * 2){
return true;
}
p = p.getParent();
}
return false;
}
示例10: findType
import com.codename1.ui.Component; //导入方法依赖的package包/类
public static <E> E findType(Class<E> clazz, Component comp) {
while (comp != null && !clazz.isInstance(comp)) {
comp = comp.getParent();
}
return (E) comp;
}
示例11: getRootAncestor
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* Returns either the parent form or the component below the embedded container
* above c.
*
* @param c the component whose root ancestor we should find
* @return the root
*/
protected Container getRootAncestor(Component c) {
while(c.getParent() != null && !(c.getParent() instanceof EmbeddedContainer)) {
c = c.getParent();
}
if(!(c instanceof Container)) {
return null;
}
return (Container)c;
}
示例12: Stats
import com.codename1.ui.Component; //导入方法依赖的package包/类
public Stats(Component c) {
name = c.getName();
type = c.getClass().getName();
uiid = c.getUIID();
if(c instanceof Label) {
Image l = ((Label)c).getIcon();
if(l != null) {
imageName = l.getImageName();
}
}
if(c.getParent() != null) {
parentName = c.getParent().getName();
}
}
示例13: setParentsVisible
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* Turns on the visibilty of all ancestors of the given component
*
* @param cmp The component to work on
*/
private void setParentsVisible(Component cmp) {
Container cont=cmp.getParent();
while (cont!=null) {
cont.setVisible(true);
cont=cont.getParent();
}
}
示例14: clipOnLWUITBounds
import com.codename1.ui.Component; //导入方法依赖的package包/类
/**
* Clips the RIM native graphics based on the component hierarchy within LWUIT
* so the native RIM component doesn't paint itself above other components such
* as the forms title.
*/
private int clipOnLWUITBounds(Component lwuitComponent, Graphics rimGraphics) {
int result = 0;
Component parent = lwuitComponent;
while (parent != null) {
int x = parent.getAbsoluteX() + parent.getScrollX();
int y = parent.getAbsoluteY() + parent.getScrollY();
rimGraphics.pushRegion(x, y, parent.getWidth(), parent.getHeight(), 0, 0);
rimGraphics.translate(-rimGraphics.getTranslateX(), -rimGraphics.getTranslateY());
parent = parent.getParent();
result++;
}
return result;
}
示例15: expandNodeImpl
import com.codename1.ui.Component; //导入方法依赖的package包/类
private Container expandNodeImpl(boolean animate, Component c) {
Container p = c.getParent().getLeadParent();
if(p != null) {
c = p;
}
c.putClientProperty(KEY_EXPANDED, "true");
if(openFolder == null) {
FontImage.setMaterialIcon(c, FontImage.MATERIAL_FOLDER, 3);
} else {
setNodeIcon(openFolder, c);
}
int depth = ((Integer)c.getClientProperty(KEY_DEPTH)).intValue();
Container parent = c.getParent();
Object o = c.getClientProperty(KEY_OBJECT);
Container dest = new Container(new BoxLayout(BoxLayout.Y_AXIS));
parent.addComponent(BorderLayout.CENTER, dest);
buildBranch(o, depth, dest);
if(isInitialized() && animate) {
// prevent a race condition on node expansion contraction
parent.animateHierarchyAndWait(300);
if(multilineMode) {
revalidate();
}
} else {
parent.revalidate();
}
return dest;
}