1

我在表单上添加了一个名为 的btnBar容器boxlayout(x-axis)。容器有 4 个自定义类的按钮,MyButton它们从Button自身扩展。当我添加actionlistener到容器中的一个按钮时,每个按钮都会调用它。即使该actionevent.getsource.gettext方法返回相同的值,而与焦点无关。我已经通过数组添加了按钮,我尝试使用的是这样的:

btns[0].addActionListener(......)

我哪里错了?

4

2 回答 2

1

got is solved buddies...actually was using setfocus() to traverse within the btnBar on buttons...but needed to use setFocused() method of form too....after setFocus()....dnt hammer ur brains now....

于 2010-02-06T10:41:34.420 回答
0

You must never use setFocus, you should use setFocusable to toggle focusability and requestFocus to get the focus to a specific component.

You should also migrate to Codename One, since LWUIT is pretty much unmaintained.

于 2013-08-18T19:18:45.283 回答