Search code examples
javablackberrylistenerjde

Blackberry JDE FieldChangeListener


I'm sort of confused as to how to implement a FieldChangeListener in the Blackberry JDE. One way has me make my main class implement FieldChangeListener, and then have a fieldchanged method inside of it, and another has me do:

    FieldChangeListener listenerUS = new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
System.out.println("Something changed!");
pushScreen(_newScreen);
}
};

Either way, if I try to call a method (like pushScreen, or a custom method I've written), I get a runtime error. In debug mode, none of my print statements are being displayed, either. However, if I remove the fieldChanged method outright, it won't even compile, so I"m pretty sure it's seeing the code?

I've added the listener to the button I want it hooked up to either by having:

            but_temp.setChangeListener(this);

(in the first case) or by putting listenerUS.

Everything seems to be hooked up, but of my print statements show up, and if I call a method, I get a runtime error.

Does this make sense? Am I just completely confused about how to use listeners on the blackberry?

http://pastie.org/618950

There's a copy of my code as a whole...


Solution

  • I'm super confused, but I managed to fix things. I created a new class from scratch, and then just copied and pasted my old code into it. Everything works. The only thing I changed was only importing classes that Eclipse said was necessary (before I had some import statements from various tutorials, etc. so some were possibly not being used.)

    Is it possible I was importing something that was causing things to crash?

    I really would rather have most of my code in the screen itself, but trying that crashes the whole thing before I can even load. Something about the xml parser I'm using not being happy.

    http://pastie.org/621932

    There's the modified code. I'm really frustrated, because I know that there is some inherent UNDERSTANDING of this frame work that I'm not grokking, and that most of my troubles are coming from this. I suppose only practice will help me, though ^_^;;