Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

lcdui - List vs ChoiceGroup (midp1.0)

Thread view: 
David N. Welton - 07 Nov 2005 09:46 GMT
Hi,

I have a question regarding the MIDP1.0 lcdui 'widgets' ChoiceGroup and
List.

Basically - is there any reason to use List for anything other than a
'menu'?  ChoiceGroup has an itemstatelistener so that you can write code
that acts immediately when a choice element has been selected, whereas
List doesn't really have this ability for MULTIPLE or EXCLUSIVE type
lists.  This has been corrected with MIDP2.0, but I'm interested in
writing code for the widest possible audience, and since 1.0 is still
being sold... 2.0 isn't an option.

I have half an idea to create ListBox and Menu classes, that are
respectively, a Form with only a ChoiceGroup in it, and a List of
IMPLICIT type.

Thoughts?
Signature

David N. Welton
- http://www.dedasys.com/davidw/

Linux, Open Source Consulting
- http://www.dedasys.com/

Darryl L. Pierce - 07 Nov 2005 13:02 GMT
> Basically - is there any reason to use List for anything other than a
> 'menu'?  

Yes. For example, it can be used for a screen where the only interaction
for the user is to select one or more items from a series of things. One
application I worked on used List screens to drill down to which
specific printer the user wanted to access through our application.
Doing that on a Form containing ChoiceGroup objects wouldn't have been
feasible since the waterfall updating of lists would've made the
interface messy and unresponsive.

Also, don't use List to create menus. That breaks UI paradigm for the
handset. Use Command objects and let the handset present them like any
other list of commands on the handset. This will make your application
more portable.

Signature

Darryl L. Pierce <mcpierce@gmail.com>
Visit my homepage: <http://mcpierce.multiply.com>
"By doubting we come to inquiry, through inquiry truth." - Peter Abelard

David N. Welton - 07 Nov 2005 13:12 GMT
>> Basically - is there any reason to use List for anything other than a
>> 'menu'?  

Perhaps I should define 'menu' better - or what I mean by it:

A list of options on the screen that cause some action to be performed
when one is selected.  This is basically what you get with an 'IMPLICIT'
List if you redefine the SELECT_COMMAND to do something interesting.

> Yes. For example, it can be used for a screen where the only interaction
> for the user is to select one or more items from a series of things. One
[quoted text clipped - 3 lines]
> feasible since the waterfall updating of lists would've made the
> interface messy and unresponsive.

If your application functions by doing something immediately when a List
item is selected, then yes, a ChoiceGroup would have looked wrong too.

I'm not clear if we're writing at cross purposes though... did your
application work like my description of menu, or were your lists
EXCLUSIVE or MULTIPLE and acted on by a Command?

Perhaps I could rephrase my question in a different way:

In the case where I want to display a series of items that are either
EXCLUSIVE or MULTIPLE, are there any disadvantages to a single
ChoiceGroup on a form?  The advantage to the ChoiceGroup is that you can
run code immediately on selection of an item.  For example: a checklist
(so MULTIPLE), where some action happens when you check off the last
item in the list.

> Also, don't use List to create menus. That breaks UI paradigm for the
> handset. Use Command objects and let the handset present them like any
> other list of commands on the handset. This will make your application
> more portable.

Makes sense to me.

Thanks,
Signature

David N. Welton
- http://www.dedasys.com/davidw/

Linux, Open Source Consulting
- http://www.dedasys.com/

David N. Welton - 07 Nov 2005 16:17 GMT
> In the case where I want to display a series of items that are either
> EXCLUSIVE or MULTIPLE, are there any disadvantages to a single
> ChoiceGroup on a form?  The advantage to the ChoiceGroup is that you can
> run code immediately on selection of an item.  For example: a checklist
> (so MULTIPLE), where some action happens when you check off the last
> item in the list.

What I was thinking of was this, maybe with a bit of tweaking:

import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.ChoiceGroup;

public class ListBox extends Form {
   ChoiceGroup cg = null;

   public ListBox(String title, int choicetype, String []choices) {
    super(title);
    cg = new ChoiceGroup("", choicetype, choices, null);
    this.append(cg);
   }

   public int append(String item) {
    return cg.append(item, null);
   }
}

Ciao,
Signature

David N. Welton
- http://www.dedasys.com/davidw/

Linux, Open Source Consulting
- http://www.dedasys.com/

Darryl L. Pierce - 12 Nov 2005 13:34 GMT
>>> Basically - is there any reason to use List for anything other
>>> than a 'menu'?
[quoted text clipped - 5 lines]
> an 'IMPLICIT' List if you redefine the SELECT_COMMAND to do something
> interesting.

There are many uses for a List object. It's the LCDUI equivalent of a
group of either radio buttons or checkboxes depending on whether your
application needs exclusive or multiple options set.

> If your application functions by doing something immediately when a
> List item is selected, then yes, a ChoiceGroup would have looked
> wrong too.

Having multiply sets of directly related but mutually exclusive
selections implies an immediate response.

> I'm not clear if we're writing at cross purposes though... did your
> application work like my description of menu, or were your lists
> EXCLUSIVE or MULTIPLE and acted on by a Command?

Exclusive. The selections in the second group depend directly on what's
selected in the first group.

> Perhaps I could rephrase my question in a different way:
>
> In the case where I want to display a series of items that are either
>  EXCLUSIVE or MULTIPLE, are there any disadvantages to a single
> ChoiceGroup on a form?

The only advantage to using a ChoiceGroup on a Form is that you can have
other Item objects on the screen as well. This can be good if those
other items and the ChoiceGroup interact with each other in some way,
but it's definitely bad in that it's cluttering up a small display with
items that might end up not being visible.

> The advantage to the ChoiceGroup is that you can run code immediately
> on selection of an item.  For example: a checklist (so MULTIPLE),
> where some action happens when you check off the last item in the
> list.

No, not quite. Have you actually read the API for ItemStateListener? It
is not guaranteed to fire at any point in time, let alone when options
are toggled in a ChoiceGroup. Be careful in your assumptions.

Signature

Darryl L. Pierce <mcpierce@gmail.com>
Visit my homepage: <http://mcpierce.multiply.com>
"By doubting we come to inquiry, through inquiry truth." - Peter Abelard



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.