Good way to maintain Muliple level selection menu list in J2ME

Posted by geoaxis on Stack Overflow See other posts from Stack Overflow or by geoaxis
Published on 2010-03-29T23:14:15Z Indexed on 2010/03/29 23:23 UTC
Read the original article Hit count: 326

Filed under:
|

Hello, I need a good way to maintain multiple form level data for menue selection. So for example If I have A and B, each might Have 1 2 3 so A A1 A2 A3 B B1 B2 B3

And this can continue for long, so that I could have A -> A1 -> A1.1 -> A1.1.1 -.... I have the following class in place, works ok But I suspect we could have better.

I just need to perform selection ni a selection tree like Widget, but each level of selection comes in another form (in J2ME)

import java.util.Vector;
 public class Tag {
    private String tag;
    private Vector childTags;
    private Tag parent;

    Tag(String tag, Vector childtag)
    {
        this.tag = tag;
        this.childTags= childTags;
    }

    public void setChildTags(Vector childTags) {
        this.childTags = childTags;
    }

    public Vector getChildTags() {
        return this.childTags;
    }

    public String getTag() {
        return this.tag;
    }


    public String toString(int depth)
    {
                String a  ="";
        if(depth==0)
        {
            a = a + this.getTag();
        }

        if(this.getChildTags()!= null)
        {

                    for(int k=0;k <this.getChildTags().capacity(); k++)
                      {
                                for (int i=0; i<depth; i++ ) {
                                        a = a + ("-");
                                }
                                a = a+ ( ((Tag)this.getChildTags().elementAt(k)).toString(depth++));
        }   }
    return a;
        }


}

© Stack Overflow or respective owner

Related posts about j2me

Related posts about java