Hello,

Please help me!

I have stored values ( many types of variables) in an arraylist.
They are values of linguistic pattern, trigger word, relevant count, irrelevant count and total count , relevant rate, rank.
Their length is different from one to another. For example, linguistic pattern may be such as <sub> active-verb
or
passive-verb prep <np>
or
gerund < obj >

I would like to show that values in the list box.
Here is my program.

public frmlist(ArrayList p,int mn) {  enableEvents(AWTEvent.WINDOW_EVENT_MASK);    ArrayList pp=new ArrayList();    String x1=new String("Linguistic  Trigger             Relevant  Irrelevant  Total  Relevant       ");    pp.add(x1);    String x3=new String("Pattern     Verb                Conunt    Count       Count  Rate       Rank");    pp.add(x3);    String x2=new String("                                        ");for( int f = 0; f < p.size(); f++){String xx=new String(); x1=lptn[((Crules)p.get(f)).lp-1];xx=x1+x2.substring(0,35-x1.length());x1=""+((Crules)p.get(f)).tri;xx=xx+x1+x2.substring(0,15-x1.length());x1=""+((Crules)p.get(f)).count;xx=xx+x1+x2.substring(0,16-x1.length());x1=""+((Crules)p.get(f)).count1;xx=xx+x1+x2.substring(0,17-x1.length());x1=""+((Crules)p.get(f)).totalcount;xx=xx+x1+x2.substring(0,12-x1.length());x1=""+((Crules)p.get(f)).relrate;xx=xx+x1+x2.substring(0,14);x1=""+((Crules)p.get(f)).rank;xx=xx+x1;//+x2.substring(0,12-x1.length())pp.add(xx);}jList1 = new JList(pp.toArray()); 
jList1.setVisible(true)

But it looks very untidy like that.
How can I do?

linguistic trigger relevant irrelevant total relevant rank
pattern verb count count count

<sub> active-verb hit 1.0 0.0 1.0 1.0 0.0
active-verb prep <dobj> 0.0 1.0 1.0 0.0 0.0
gerund <dobj> 2.0 1.0 3.0 2.0 1.0
noun prep <np> 1.0 0.0 1.0 1.0 0.0


How can i show them in systematically?
Please help me.
I am sorry if you don't understand and feel upset because you don't understand what I am trying to say. I am weak in English.

Thank you very much!


Hello! Although I use code tag, my program appear like that. I am sorry. I use

and

.

You could try placing one or more "\t" between each value. That way your code will be spaced evenly.

eg:

String s = "Hello";
s += "\t";
s += "how are you";

It will print like so:
Hello____________how are you

(there will not be any underscores, ("_") in the print statement. I just need to put them in, because the form is removing multiple spaces)

Hello,
Thank you for ur reply.
But I think i can not use \t.

The format I would like to show is to play title and put their values under that title.


Please help me!

You could try placing one or more "\t" between each value. That way your code will be spaced evenly.

eg:

String s = "Hello";
s += "\t";
s += "how are you";

It will print like so:
Hello____________how are you

(there will not be any underscores, ("_") in the print statement. I just need to put them in, because the form is removing multiple spaces)

I don't know why I can not use this forum properly today. I can not show you the format I would like to write.
So please see the format of titled Similar Threads in this page.
In that format , there are 5 titles, thread, thread starter, forum, replies and last post.
Like that , I have titles like that
Linguistic pattern, relevant count, irrelevant count, total count , relevant rate and rank.
I have also save their values in the arraylist.
I don't know how to show them.

I don't understand what you are asking? Could you try demonistrating what you are looking for?

If you are using JDK 1.5 or later, check out the "format" method of String. And actually follow and read (completely) the "format string" link contained within the description for that method.

Hello,
I use HTML to format the text in the list item strings.
But it does not work.
What is the problem?

public frmlist(ArrayList p,int mn) {
 enableEvents(AWTEvent.WINDOW_EVENT_MASK);
 ArrayList pp=new ArrayList();
String[] items;
for( int f = 0; f < p.size(); f++)
{String x1=new String();
String xx=new String();
String xx1=new String();
 
x1=lptn[((Crules)p.get(f)).lp-1];xx=x1;
x1=""+((Crules)p.get(f)).tri;xx=xx+x1+"   ";
 
//x1=""+((Crules)p.get(f)).lp;xx=x1+x2.substring(0,12-x1.length());
//x1=""+((Crules)p.get(f)).tri;xx=xx+x1+x2.substring(0,13-x1.length());
x1=""+((Crules)p.get(f)).count;xx=xx+x1+"   ";
x1=""+((Crules)p.get(f)).count1;xx=xx+x1+"    ";
x1=""+((Crules)p.get(f)).totalcount;xx=xx+x1+"    ";
x1=""+((Crules)p.get(f)).relrate;xx=xx+x1+"   ";
x1=""+((Crules)p.get(f)).rank;xx=xx+x1;//+x2.substring(0,12-x1.length())
xx="<HTML><pre>" + xx+ "</pre></HTML>";
pp.add(xx);
}
//JList jlist = new JList(items);
jList1 = new JList(pp.toArray());
jList1.setVisible(true);
}
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.