displaying Arraylist in label

Jo, i want to display my list in a label on an actionevent, i want to have each item on a new line. This is how far i got. Can somebody help plz

i declared my arraylist btas in my public class

public void jTextField1_actionPerformed(ActionEvent e) {

btas.add(jTextField1.getText());

int aantal = btas.size();

display();

}

public void display(){

String next= "\n";

jLabel1.setText("");

for (int i=0; i<btas.size();i++) jLabel1.setText(next+btas);>

[519 byte] By [muckva] at [2007-11-26 22:19:26]
# 1

[nobr]\n won't work - HTML will. You could use something likeStringBuilder builder = new StringBuilder ();

for (Object element: list) { // or whatever's the type of your list

if (builder.length () > 0) {

builder.append ("<br>");

}

builder.append (String.valueOf (element));

}

label.setText (String.format("<html>%s</html>", builder.toString ());

[/nobr]

levi_ha at 2007-7-10 11:15:25 > top of Java-index,Java Essentials,New To Java...
# 2
would \n work in something else, like a textArea or something (wich i tried but could not draw one in the design cause of nullpointerexeption)
muckva at 2007-7-10 11:15:25 > top of Java-index,Java Essentials,New To Java...
# 3
Yes, that'd work fine.
levi_ha at 2007-7-10 11:15:25 > top of Java-index,Java Essentials,New To Java...