I have a table that outputs certain rows.But they are from different groups and the different groups are stored in different vectors.At present i am adding all the rows using the following code :

m_vector.addAll(match1);
m_vector.addAll(match2);
..
m_vector.addAll(matchn);

Here match 1 to match n are the different sections.I Want to insert rows in between these statements that act as separators of these sections.


Now I want to add a separator between different sections (a group of rows) of my table. And I want to be able to put text in it too, to describe what the different sections are about. What is the best approach to do this, especially in terms of simplicity of implementation (cause I already have a bunch of code working a certain way, I want to minimize the changes, if any needed...).

If you look at the API of the Vector class you will see that there is a method that lets you add an element at a specific place. I think it is like this:

add(int i, Object obj);

Look at it, but if I remember correctly, it adds it to the int "place" and whatever was at that place it is shifted to the "end"

Yes there is a function that takes in an int and the object.But my vector is of a particular datastructure and I want to just enter a string in that row.Also i want to get the row dynamically..in the program.How do i achieve that?

Yes there is a function that takes in an int and the object.But my vector is of a particular datastructure and I want to just enter a string in that row.Also i want to get the row dynamically..in the program.How do i achieve that?

You could do this:

Vector v = new Vector();
v.add("1");
v.add(someObject1);
v.add(someObject2);
v.add("2");

for (int i=0;i<v.size();i++) {
   Object obj = v.get(i);
   if (obj instanceof String) {
          // seperate rows
   } else if (obj instanceof SomeObject) {
       SomeObject so = (SomeObject)v.get(i);
   }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.