Good way to maintain Muliple level selection menu list in J2ME
- by geoaxis
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;
}
}