Amrit
Amrit

Reputation: 1

why this code is not working?

accountTab.setChangeListener(new FieldChangeListener() {
   public void fieldChanged(Field field, int context) {
      if (field==TabBar.accountTab)  {
         Dialog.alert(" Account Tab is clicked ");
      }
   }
});

why this code is not working? but some places it works. I am ceating the tab bar for 9800 torch with Horizontal field manager and "accountTab" in this code is the custom button field. Please Help me.........

Upvotes: 0

Views: 163

Answers (3)

Dan
Dan

Reputation: 1002

does the callback fire? have you attached a debug breakpoint to the conditional to see if it actually calls? if so, then @Fostah's answer above is a pretty good place to start, you may not be in the event dispatch thread when this callback fires...

Upvotes: 0

jprofitt
jprofitt

Reputation: 10974

If you are attaching a FieldChangeListener to one Field, you shouldn't really need to test whether or not it is the Field (unless you're doing something very custom). I would try debugging and see whether or not the fieldChanged call is getting hit, and if you want to use the test in there, make sure TabBar.accountTab is actually a reference to what you think it is.

Another possibility is that you haven't set the tab as FOCUSABLE, or possibly you have something further up the chain intercepting the clicks and not allowing it to proceed further.

Upvotes: 1

Fostah
Fostah

Reputation: 11776

The information provided is too vague to know the exact problem. However, there's a good chance it has to do with the fact that you're trying to open a dialog in response to an event and you might not currently be holding the event lock. Use Application#invokeLater() to open the dialog. You'll need to implement Runnable and make the Dialog.alert call from the run method.

Upvotes: 0

Related Questions