我正在尝试刷新合成中的clabel。然而,clabel并不总是存在。我需要一种方法来检查复合中是否存在。我已经在复合上尝试了getChildren
类,并且我已经能够使用它来查找复合体上的所有CLabel
,但是我无法解析它们。
这是我到目前为止所拥有的
Control[] childs = comp.getChildren();
for (int i = 0; i < childs.length; i++) {
if(childs[i].getClass().getSimpleName().equalsIgnoreCase("CLabel")){
}
}
答案 0 :(得分:2)
为什么不使用instanceof
然后再施展呢?
Control[] children = comp.getChildren();
for (int i = 0; i < children.length; i++)
{
if(children[i] instanceof CLabel)
{
CLabel label = (CLabel) children[i];
/* Do something with the label */
}
}