Re: Removing all data out of JList
Roedy Green wrote:
On Mon, 05 Nov 2007 16:59:46 +0000, Nigel Wade <nmw@ion.le.ac.uk>
wrote, quoted or indirectly quoted someone who said :
The API could
have told you that...
the JavaDoc says "Removes all the components from this container. This
method also notifies the layout manager to remove the components from
this container's layout via the removeLayoutComponent method."
I consider it a gotcha. You could quite easily consider the values of
the list as components.
You should really read the documentation for, and understand the workings of,
components you are using when you program a GUI. To confuse the contents of a
ListModel with a Component means you really haven't understood what's going on.
However, I think it's a case of IDEitis (a somewhat similar disease to
calculatoritis which undergraduate physicists suffer from). In this case a
programmer enters the name of their JList variable into the IDE and up pops a
list of all its methods, including those it inherits. The programmer then
scrolls down the list searching for a method with a likely looking name and
uses it without looking up in the API what it actually does.
--
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