Link to home
Start Free TrialLog in
Avatar of j_baxter99
j_baxter99

asked on

Adding text to jlist

how do i add text to a jlist and make it visible?

an example please
Avatar of expertmb
expertmb

hi,
 try this
 String [] str = {"aa","bb"};
 JList list = new JList(str);
 
mb...
Avatar of j_baxter99

ASKER

Yep i can do that but i want to add to how do i add contents to it dynamically.
e.g

String [] str = {"aa","bb"};
 JList list = new JList(str);

and now i want to add "cc" to my list

how do i do it?
cheers
also how do i update it when it is added, i.e refresh the list.
ok i have it but how do i get it to scroll
Dear j_baxter99,

JList list = new JList(str);
list.addItem("How are you?");

It will get automatically scrolled when the list is growing.

Bye

Murali
thats is only for a awt.List it doesnt work that way for JList`s muralirm
hi,
 inorder to get scrollbar add the Jlist to JScrollPane u will get the scroll bar.

mb...
cant get the scroll pane to become visible ???
ASKER CERTIFIED SOLUTION
Avatar of ovidiucraciun
ovidiucraciun
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
 jscrollpane.getViewport().add(list, null).