1

I have added a container named btnBar with boxlayout(x-axis) on a form. the container has 4 buttons of custom class MyButton that extends from Button itself. When i add actionlistener to one of the buttons in the container it gets invoked for each n every button. Even the actionevent.getsource.gettext method returns the same value irrespective of the focus. I have added the buttons through an array and m trying to use is something like this:

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

Where am I going wrong?

Malachi
  • 33,142
  • 18
  • 63
  • 96
user267674
  • 21
  • 3

2 Answers2

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....

user267674
  • 21
  • 3
  • You should accept this answer to remove this question from the list of unanswered questions. – Rob Aug 24 '12 at 18:00
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.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65