File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes ItemStateListener and itemStateChanged() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "ItemStateListener and itemStateChanged()" Watch "ItemStateListener and itemStateChanged()" New topic
Author

ItemStateListener and itemStateChanged()

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I recently bought the book Core J2ME Technology and am working through the examples. I'm having a problem with the ItemStateListner stuff. I understand that the MIDP specification says that itemStateChanged() doesn't have to be called every time a change occurs. However, I don't understand why this is.
In fact, in the first example for ItemState events on page 117, the itemStateChanged() method is never called. I can change the DateField item as many times as I want, and it still isn't called.
I thought this might just be a fluke, but I came to a similar example for a snooze MIDlet. The same thing happens: when the date/time is changed the event never fires.
What is going on here? What's the point of an event handler that is never called? I'm very confused about this issue.
I know I should probably post some code, but I think that might be a bit premature at this point. If you have the book, the examples are on page 117 (CaptureItemEvents.java) and page 132 (Snooze.java).
I am developing with the Linux version of MIDP. Perhaps it has to do with this specific implementation?
Any comments will be greatly appreciated.
Regards,
Layne


Java API Documentation
The Java Tutorial
john muchow
Ranch Hand

Joined: Mar 24, 2001
Posts: 49
>In fact, in the first example for ItemState
>events on page 117, the itemStateChanged()
>method is never called. I can change the
>DateField item as many times as I want, and it
>still isn't called.
This must be an error with the implementation.
If you look at page 119, you will see the screen shot that I captured (right most figure), showing the result once the event is executed.
What implementation are you using? Feel free to forward the examples to the developers to show the problem.
Regards,
John Muchow
john@corej2me.com
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Sorry, I forgot to mention the developer. I'm using Sun's implementation for Linux. I guess I assumed that their own implementation would handle this correctly. I thought I'd done something wrong. Maybe I just need to go over the code to make sure it is the exact same as the listing in your book...
john muchow
Ranch Hand

Joined: Mar 24, 2001
Posts: 49
Hi Layne,
When you have a chance, send me the code you have written. Although I don't have the Linux install, I will run the code on my machine and see if it runs.
If it does, we can decide how to proceed from there.
Thanks,
John
john@corej2me.com
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Will do. I also downloaded the source code from your site so I can do a diff with the code I typed in. Usually I avoid downloading source code because typing the examples usually helps me learn the concepts better.
Well, thank you for your time. I sure would like to figure out what the problem is...
Layne
David Carlson
Greenhorn

Joined: Dec 14, 2004
Posts: 1
Now it's 12/14/2004 I'm having the same itemStateListener issues. What was the solution?
Edward Durai
Ranch Hand

Joined: Oct 09, 2004
Posts: 223
Steps :1

implements the itemStateListener in class

Step :2

add method like public void itemStatechanged(Item item){
++++++action+++++
}

step :3

add itemStateListener
display.setCurrent(form);

Thanks
further
edward_durai@hotmail.com


Thank You<br />Edward
Andrea Cacciarru
Greenhorn

Joined: Feb 09, 2006
Posts: 2
I have the same problem too. If I try Muchow's example in my Sun wireless toolkit everything works fine, but if I try Snooze example in my LG U8180 mobile, the itemStateChanged don't works! Maybe can it depend by the LG's JVM implementation?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ItemStateListener and itemStateChanged()