我是codenameone的新手 .
我使用ClassName AppSplash在新的Gui Builder中创建了一个Form Component . 在那个AppSplash类中,来自Gui我有两个容器“Container1”和“Container2” . 在Container2内部,我有一个名为“Memebers_Count”的标签 . 我从另一个类中实例化这个AppSplash
AppSlpash as = new AppSplash()
如何访问标签“Members_Count”以更改其显示的文本?
我试着做一些像as.getComponentAt(0).getComponentAt(1)
但第二个getComponentAt(1)在Netbeans中显示为erron,注意“找不到符号:getComponentAt(1)”,而第一个getComponentAt不是错误的 .
任何帮助都是值得赞赏的
1 回答
做这样的事情通常被认为是不好的 . 您将依赖于第二种形式的结构,对结构的任何微小改变都可能会破坏它 .
正确的解决方案是在第一种形式中添加方法,例如:
然后在第二种形式做:
您可能需要转换为正确的类型,例如
((SecondFormClassName)secondForm).setMemberCount(value);
.